while loop:
<tbody>
<?php while($row=$result->fetch_assoc()){ ?>
<tr>
<td><?= $row['id']; ?></td>
<td><?= $row['fornavn']; ?></td>
<td><?= $row['efternavn']; ?></td>
<td><?= $row['mail']; ?></td>
<td><?= $row['kursistnummer']; ?></td>
<td><?= $row['unilogin']; ?></td>
<td>
<a href="read.php?id='. $row['id'] .'" class="mr-3" title="View Record" data-toggle="tooltip"><span class="fa fa-eye"></span></a>
</td>
</tr>
<?php } ?>
</tbody>
when I press the a href for each record it always results in this url
http://localhost/helloworld/read.php?id=%27.%20$row%5B%27id%27%5D%20.%27
I think its the syntax of the —- > href="read.php?id='. $row['id'] .'" but I’ve tried all the variations that I can find as a php beginner, it’s driving me nuts!
>Solution :
PHP shorthand tag for echo is missing in href link.
This Code snippet should work:
<a href="<?= 'read.php?id='. $row['id'] ?>" class="mr-3" title="View Record" data-toggle="tooltip"><span class="fa fa-eye"></span></a>