Milon Sarker
Milon Sarker

Reputation: 478

Parse Error in css/html when they are inside PHP code

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
  {

  }
?>

Upvotes: 0

Views: 45

Answers (2)

Peyman Mohamadpour
Peyman Mohamadpour

Reputation: 17954

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
}?>

Upvotes: 1

jedrzej.kurylo
jedrzej.kurylo

Reputation: 40909

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 {

}

Upvotes: 2

Related Questions