<a href= \"edit_form.php?id = $row[ID]\">Edit</a>
How can I pass variable in href? Is my code syntax correct? I want to pass the variable to another PHP file.
Can someone help? Thanks!
You're almost there. Spaces are not allowed in urls.. so you need to remove those. Not to mention as this html is not in an echo, you need to enclose the $row
variable in php syntax:
<a href="edit_form.php?id=<?php echo $row['ID']; ?>">Edit</a>
Try like this
echo '<a href="edit_form.php?id='. $row[id] .'" >Edit</a>';
if you want to send the values through the anchor
Simplest way to pass values via url (not the safest way tho) -
<a href="edit_form.php?id=<?php echo $row[id] ;?> " >Edit</a>
OR
echo '<a href="edit_form.php?id='. $row[id] .'" >Edit</a>';
Whatever suits your scripting...