I'm developing a small project in which I use a loop to display all the contents of a database table in an HTML table. For each row I need a clickable button that, if pressed , can "remember" the ID of the table's element to witch it corresponds. I've some problem with the href of the link. That's my code:
<td>
<a href="modifica.php?id=<?php echo $row[ ' ID '] ?> " class="waves-effect waves-light btn"><i class="small material-icons right">mode_edit</i></a>
</td>
I've also tried this:
<td>
<a href="modifica.php?id='<?php echo $row[ ' ID '] ?> ' " class="waves-effect waves-light btn"><i class="small material-icons right">mode_edit</i></a>
</td>
Can anyone help me please? Thanks!
You're not setting any $_GET variable name in your href
attribute.
Try replacing
<a href="modifica.php?=<?php echo $row['ID']; ?>" class="waves-effect waves-light btn"><i class="small material-icons right">mode_edit</i></a>
By
<a href="modifica.php?id=<?php echo $row['ID']; ?>" class="waves-effect waves-light btn"><i class="small material-icons right">mode_edit</i></a>
Basically, I've added id between the ?=. And removed the space in your $row[' ID ']
modifica.php?id=
Instead of
modifica.php?=
I've removed the space in the index of the $row variable because $row[' ID ']
is not the same as $row['ID']
.