Php 在while循环项中指定唯一ID

Php 在while循环项中指定唯一ID,php,while-loop,Php,While Loop,如何为while循环中的项目提供uniuqe ID 例如: while ($row = mysql_fetch_array($query)){ echo "$row['items']; <a href=\"GoToPageToEditThisItem\">Edit</a>"; } while($row=mysql\u fetch\u array($query)){ 回显“$row['items'];”; } 输出: 因此,我可以编辑适当的项目 $id=0; $id

如何为while循环中的项目提供uniuqe ID

例如:

while ($row = mysql_fetch_array($query)){
 echo "$row['items']; <a href=\"GoToPageToEditThisItem\">Edit</a>";
}
while($row=mysql\u fetch\u array($query)){
回显“$row['items'];”;
}
输出:

因此,我可以编辑适当的项目

$id=0;
$id = 0;
while ($row = mysql_fetch_array($query)){
 $id = $row['id'];
 echo $row['items'].'<a href=\"GoToPageToEditThisItem\id\$id">Edit</a>';
}
while($row=mysql\u fetch\u array($query)){ $id=$row['id']; echo$row['items'.'”; }
假设您的表中有一个ID(自动递增/唯一)

while ($row = mysql_fetch_array($query)){
 echo $row['items'] . '<a href="editItem.php?id=' . $row['id'] . '">Edit</a>';
}
while($row=mysql\u fetch\u array($query)){
echo$row['items'.'”;
}

然后,您可以使用
$\u GET[“id”]

访问该项。您的表是否包含唯一的/primary/auto\u增量索引?请参阅“确定”,但项目存储在数据库中。项目1可以作为项目99存储在数据库中。啊,我在想,我已经知道$itemId了,所以简单地id=$itemId就足够了。。。谢谢你们!“假设您的表中有一个唯一的ID”-并且假设您在href=“…”属性中作为参数打印时不必注意正确的编码/转义;-)完美的解决方案,谢谢你,本!