2014-02-20 34 views
0

我需要過濾一個會話表,通常這是我如何顯示錶列表。PHP搜索,只顯示會話ID日誌

<?php 
$con=mysqli_connect("localhost","root","","esc"); 
// Check connection 
if (mysqli_connect_errno()) 
{ 
echo "Failed to connect to MySQL: " . mysqli_connect_error(); 
} 

$result = mysqli_query($con,"SELECT * FROM sponsor ;"); 

echo "<table border='1'> 
<tr> 
<th>ID</th> 
<th>PIN</th> 
<th>Author</th> 
<th>Author ID</th> 
<th>Entry Date</th> 
</tr>"; 

while($row = mysqli_fetch_array($result)) 
{ 
echo "<tr>"; 
echo "<td>" . $row['sid'] . "</td>"; 
echo "<td>" . $row['spin'] . "</td>"; 
echo "<td>" . $row['spuname'] . "</td>"; 
echo "<td>" . $row['suid'] . "</td>"; 
echo "<td>" . $row['sdate'] . "</td>"; 
echo "</tr>"; 
} 
echo "</table>"; 

mysqli_close($con); 
?> 

我想知道是否有可能在這部分...

$result = mysqli_query($con,"SELECT * FROM sponsor ;"); 

添加Where spuname = 'spuname'

我想我這樣做是錯誤的方式。

我想要做的是顯示過濾的表,因此具有該會話的人將只能看到他的日誌。

+0

spuname?因此,您可以將它傳遞給查詢 – Chitowns24

+0

'spuname'存儲@ sponsor表,它是成員輸入數據的表。 @ Chitowns24 – PHPNewbie

+0

'SELECT * FROM sponsor where spuname ='spuname'' ...就像你說的那樣。 –

回答

0

您可以在查詢中使用where子句。這將是

$result = mysqli_query($con,"SELECT * FROM sponsor Where spuname = 'spuname'");
+0

這樣做,但它沒有顯示任何內容。 '贊助商'表,其中'spuname'就像一個時間戳,一旦來自成員表的'session id'得到了會話,它就會自動填充。 @Manoj Saini – PHPNewbie

0
mysqli_query("SELECT * FROM sponsor Where spuname = 'spuname'",$con); 

嘗試把$ CON查詢後肯定是可能的,其中存儲