[英]While Loop taking ID value for a href
while loop: while循环:
<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[%27id%27]%20.%27当我为每条记录按 a href 时,它总是会导致这个 url http://localhost/helloworld/read.php.%20=%27.%2%2[%20=%27]%2
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!我认为它的语法 ---- >
href="read.php?id='. $row['id'].'"
但我已经尝试了作为 php 初学者可以找到的所有变体,它快把我逼疯了!
PHP shorthand tag for echo is missing in href link.回声的 PHP 速记标记在 href 链接中丢失。
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>
use ""
for the id attribute because you use ''
outside the . $row['id'].
使用
""
''
id 属性,因为您在. $row['id'].
. $row['id'].
So like this:所以像这样:
href="read.php?id='. $row["id"] .'"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.