0

I was wondering what's my problem on this code. I was just want to query the database into tables. Thanks guys

<?php
  while ($row = $query->fetch(PDO::FETCH_ASSOC))
  printf(
     "<tr>";
     "<th scope='row'>" . htmlentities($row['insrt_fullname']) . "</th>";
     "<td>" . htmlentities($row['insrt_username']) . "</td>";
     "<td>" . htmlentities($row['insrt_password']) . "</td>";
     "<td>" . htmlentities($row['insrt_email']) . "</td>";
     "<td>" . htmlentities($row['insrt_designation']) . "</td>";
     "<td>";
     '<a href=/tarp_admin/connection/delete_user.php?id=' . $user_id . ' 
class=\'badge badge-danger\' onclick="myFunction">Delete</a> <a 
href=/tarp_admin/connection/delete_user.php?id=' . $user_id . ' 
class=\'badge badge-warning\'>Edit</a>';
     "</td>";   
     "</tr>";
);
?>

Parse error: syntax error, unexpected ';' in C:\xammp\htdocs\tarp_admin\dashboard.php on line 344

Vanj
  • 1
  • 3

2 Answers2

3

You are using semicolons on each line, that's a wrong syntax: you should put a dot instead. Also, since you are including so much HTML in your routine, you might instead use:

<?php
  while ($row = $query->fetch(PDO::FETCH_ASSOC)):
?>

<tr>
<th scope='row'><?php print htmlentities($row['insrt_fullname']); ?></th>
/** ADD HERE ALL THE REST... */
</tr>

<?php
  endwhile;
?>

Much cleaner to read.

0

Use . (dot) for string concatenation instead of ; (semicolon).

Ahmad Khan
  • 2,655
  • 19
  • 25
Hamza Khan
  • 107
  • 1
  • 11