-1

I was doing CRUD operation in PHP code combined with HTML code using while. I want HTML code to repeat after every execution of while(). But it is giving error: "Parse error: syntax error, unexpected '?> ' in C:\xampp\htdocs\php\index1.php on line 21" . Anyone can solve this issue. I have mentioned the code below:

       <?php
$con=mysqli_connect("localhost","root","","student");

$sql="select * from student_php";

$res=mysqli_query($con,$sql);

?>
<table>

   <tr>
      <td>S.No</td>
      <td>Name</td>
      <td>City</td>
   
   </tr>
<?php 
 while($row =mysqli_fetch_assoc($res){ 
 ?>
   <tr>
      <td>S.No</td>
      <td><?php echo $row['name']?></td>
      <td><?php echo $row['city']?></td>
   
   </tr>
  <?php } 
?>
</table>
Rabin ghimire
  • 35
  • 1
  • 4

1 Answers1

-3

Your while loop is not closed.

while($row =mysqli_fetch_assoc($res)

needs to be

while($row =mysqli_fetch_assoc($res))
Dharman
  • 30,962
  • 25
  • 85
  • 135
my_workbench
  • 300
  • 3
  • 8
  • 1
    you need to explain with an example to be more correct and teach where the problem is an example; this || while($row =mysqli_fetch_assoc($res) || should be this || while($row =mysqli_fetch_assoc($res)) || SEE '($res))' just making a 6-word comment is not allowing them a person to see the mistake just remember when you started to code and spent 2 hours hunting for the missing semi-colon on the 10 different occasions. – Zapps Ceo Aug 03 '20 at 04:29
  • Please don't post answers only pointing out a typographical issue or a missing character. Such answers are unlikely to help future visitors since they are specific to OP's code. Instead, flag or vote to close the question as off-topic as per the [help/on-topic]. – Dharman Aug 03 '20 at 11:48