0

Trying to do this but it giving parse error... is there any way?

<?php
  if($profileIdType==1)
  {
    <li class="col-md-6">
        <label>First Name</label>
        <input type="text" class="form-control validate[required]"
               name="first_name" id="first_name" placeholder="First name" readonly="true"
               data-toggle="tooltip" title="First name">
    </li>
  }
  else
  {

  }
?>
1
  • ?> <- close php before the html and then start it again <?php before the bracket. Commented Jul 12, 2015 at 20:24

2 Answers 2

2

If you want to output HTML/CSS from your PHP script you need to close/reopen PHP tags:

<?php
if ($profileIdType == 1) {
?>
    <li class="col-md-6">
        <label>First Name</label>
        <input type="text" class="form-control validate[required]"
               name="first_name" id="first_name" placeholder="First name" readonly="true"
               data-toggle="tooltip" title="First name"
            >
    </li>
<?php
} else {

}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks ... Stackoverflow is the best thing in Internet... and its users too... @jedrzej.kurylo
1

You need to separate scripting from markup.

<?php
if ($profileIdType == 1) {?>
<li class="col-md-6">
    <label>First Name</label>
    <input type="text" name="first_name">
</li><?php
} else {?>
<li class="col-md-6">
    <label>Last Name</label>
    <input type="text" name="last_name">
</li><?php
}?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.