-2

I have three buttons , Edit remove and view .. on view part i am trying to echo the row ID in order to fetch details . But i get this parse error .

Here is the Code :

 while( $row=mysqli_fetch_array($query) ) { 
 $active = '';
 if($row['active'] == 1) {
    $active = '<label class="label label-success">Complete</label>';
 } else {
    $active = '<label class="label label-danger">Incomplete</label>'; 
 } 


 $actionButton = '
<div class="btn-group">
  <button type="button" class="btn btn-default dropdown-toggle" data-     toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Action <span class="caret"></span>
  </button>
  <ul class="dropdown-menu">
    <li><a type="button" data-toggle="modal" data-backdrop="static" data-keyboard="false"  data-target="#editMemberModal"  onclick="editMember('.$row['id'].')"> <span class="glyphicon glyphicon-edit"></span> Edit</a></li>
    <li><a type="button" data-toggle="modal" data-target="#removeMemberModal" onclick="removeMember('.$row['id'].')"> <span class="glyphicon glyphicon-trash"></span> Remove</a></li>
    <li><a class="view_data"  type="button" data-toggle="modal"   data-target="#dataModal" id="'.<?php echo $row['id']; ?>.'"><span class="glyphicon glyphicon-trash"></span> View</a></li> 
  </ul>
</div>
    ';

Am facing this error on the dropdown menu third list .. class is view_data

5
  • Does the error give you a line number?
    – Jerodev
    Commented Feb 28, 2017 at 8:41
  • Yes , Am facing this error on the dropdown menu third list .. class is view_data Commented Feb 28, 2017 at 8:41
  • 4
    Just compare how you concatenate: '.$row['id'].' and '.<?php echo $row['id']; ?>. see any difference?!
    – Rizier123
    Commented Feb 28, 2017 at 8:41
  • Yeh, if this is already within a PHP tag (which it seems to be as you have a while loop, if statements and are assigning the string to a variable) then there is no need to put more PHP tags. Simply .$row["id"]. should work. Commented Feb 28, 2017 at 8:44
  • i tried the above method '.$row['id'].' .. the error gets resolved but its not fetching the data . in console it shows member_id:<?php echo 1; ?>; but it should appear member_id: 1 ; .. it is taking <?php echo ?> as a string Commented Feb 28, 2017 at 8:46

1 Answer 1

5

Check your last li change it as per below:

<li><a class="view_data"  type="button" data-toggle="modal"   data-target="#dataModal" id="' . $row['id'] . '"><span class="glyphicon glyphicon-trash"></span> View</a></li>

Also in above code ending } is missing at last

1
  • Thanks a ton .. i replaced the third list with your code and the error got resolved Commented Feb 28, 2017 at 8:55

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.