2014-03-25 21 views
0

我目前已經做了一個顯示所有用戶的頁面,但我只想顯示當前登錄的用戶,請幫助我即時通訊乞求你我花了4個小時沒有T_T im新的在PHP和IM非常丟失,即時如此絕望現在顯示自己的數據只爲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 } ?> 
+1

看看PDO或mysqli的,因爲MySQL擴展您正在使用已經被廢棄。 – GhostGambler

回答

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 
+0

tnx爲你有幫助的答案T_T虐待我試試這 – user3185269

+0

我已經完成在URL中傳遞用戶ID,但我現在的問題是即時通訊有一個錯誤稱爲未識別的ID你知道如何解決先生? – user3185269

+0

看來customerinfo表中標識符列的名稱不是「id」。 (可能是它的Id)。你需要用WHERE條件中的有效列名替換'id =':'WHERE valididcolumn = $ id' – mesutozer

相關問題