$row[0]开发者_如何学Go
is user_id when i click on user_id i need to know how to get the value i clicked from the html table using php so i can use this id to select its data into another form so i can edit it
$select = "SELECT U.id, U.first_name, U.last_name, U.email_address, U.password, U.gender, U.day, U.month, U.year, COUNT(O.user_id) FROM users U LEFT JOIN orders O ON U.id = O.user_id GROUP BY U.id ORDER BY id $order LIMIT $offset , $rowsPerPage";
$result=mysql_query($select) or die(mysql_error());
while($row=mysql_fetch_array($result)){ ?>
<table>
<tr>
<td><?php echo "<a href= 'editUser.html'> $row[0]</a>"; ?></td>
<td><?php echo $row[1];?></td>
<td><?php echo $row[2];?></td>
<td><?php echo $row[3];?></td>
<td><?php echo $row[4];?></td>
<td><?php echo $row[5];?></td>
<td><?php echo $row[6];?></td>
<td><?php echo $row[7];?></td>
<td><?php echo $row[8];?></td>
<td><?php echo $row[9];}
</tr>
</table>
Pass as query string and will be available in $_GET
<td><?php echo "<a href= 'editUser.html?id=".$row[0]."'> $row[0]</a>"; ?></td>
You can get in next page like this
echo $_GET['id'];
You can't "get" id from HTML table.
You can only send it using a hyperlink
$select = "SELECT U.id, U.first_name, U.last_name, U.email_address, U.password, U.gender, U.day, U.month, U.year, COUNT(O.user_id) FROM users U LEFT JOIN orders O ON U.id = O.user_id GROUP BY U.id ORDER BY id $order LIMIT $offset , $rowsPerPage";
$result=mysql_query($select) or die(mysql_error());
while($row=mysql_fetch_array($result)){
$data[] = $row;
}
?>
<table>
<tr>
<? foreach($data as $row) { ?>
<td><a href="edituser.php?id=<?php echo $row['id']?>"><?php echo $row['id']?></a></td>
<? } ?>
</tr>
</table>
you can use Ajax request to send data from table to server.
精彩评论