-1

I'm trying to bring the user details by clicking on "detail" in a table (all the rows in the table are from the db) I bring the info to the table with this (code found it somewhere here),

<?php foreach ($link->query('SELECT * from data') as $row){  ?> 

<td><?php echo $row['fullname'] ?></td>

this works perfect, and on the table I add this.

<?php echo '<a href="details.php?AutoID='.$row['AutoID'].'">Details</a>'; ?>

now I'm trying to get the details for each user by using the same code in the query I used before but it doesn't work.

<?php $id = $_GET['AutoID']; 
foreach ($link->query('SELECT * from data where AutoID=$id') as $row){  ?> 

<td><?php echo $row['fullname'] ?></td>
<td><?php echo $row['email'] ?></td>
<td><?php echo $row['phone'] ?></td>

Thanks a lot, I hope I explain myself well.

1 Answers1

1

Change this

$link->query('SELECT * from data where AutoID=$id') 

to that

$link->query('SELECT * from data where AutoID='.$id)

BTW. consider use some filter for $_GET params

Bart
  • 1,268
  • 2
  • 12
  • 14