我目前已经制作了一个显示所有用户的页面,但我只是想显示当前登录的用户,请帮助我,求你了我花了4个小时没什么T_T即时新功能在PHP上我很失落,我现在很无望
<?PHP
$customerquery=mysql_query("select * from customerinfo");
while($customerrows=mysql_fetch_array($customerquery)){
?>
<tr>
<td>Id</td><td>First Name</td><td>Last Name</td><td>Address</td><td>Contact No</td> <td>Username</td><td>Password</td><td>Edit</td>
</tr>
<tr>
<td><?PHP echo $customerrows['id'];?></td>
<td><?PHP echo $customerrows['fname'];?></td>
<td><?PHP echo $customerrows['lname'];?></td>
<td><?PHP echo $customerrows['address'];?></td>
<td><?PHP echo $customerrows['contactno'];?></td>
<td><?PHP echo $customerrows['username'];?></td>
<td><?PHP echo $customerrows['password'];?></td>
<td><a href="edit2.php<?PHP echo '?id='.$customerrows['id']; ?>">edit</a></td>
</tr>
<?PHP } ?>
答案 0 :(得分:0)
您需要在查询中指定WHERE条件。这将只获取一行,因此您不需要while循环:
$id = (int) $_GET['id']; // assuming you pass user id in URL
$customerquery = mysql_query("select * from customerinfo WHERE id = $id");
$customerrows = mysql_fetch_array($customerquery);
// rest of your html