Reputation: 5
How can I give a uniuqe ID for a item in a while loop.
Example:
while ($row = mysql_fetch_array($query)){
echo "$row['items']; <a href=\"GoToPageToEditThisItem\">Edit</a>";
}
Output:http://prntscr.com/2bto7g
So I can edit the appropriate item.
Upvotes: 0
Views: 775
Reputation: 32127
Assuming you have an ID (auto incremented/unique) in your table,
while ($row = mysql_fetch_array($query)){
echo $row['items'] . '<a href="editItem.php?id=' . $row['id'] . '">Edit</a>';
}
You could then access the item using $_GET["id"]
.
Upvotes: 2
Reputation: 11984
$id = 0;
while ($row = mysql_fetch_array($query)){
$id = $row['id'];
echo $row['items'].'<a href=\"GoToPageToEditThisItem\id\$id">Edit</a>';
}
Upvotes: 0