开发者

how to get the value of a user_id link from html table using php

开发者 https://www.devze.com 2023-02-22 04:13 出处:网络
$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

$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.

0

精彩评论

暂无评论...
验证码 换一张
取 消