PHP搜索,仅显示会话ID日志

时间:2014-02-20 03:53:21

标签: php mysql sql

我需要过滤会话表,通常这是我显示表列表的方式。

<?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'

我想我这样做的方式是错误的。

我想要做的是显示已过滤的表格,因此拥有会话的表格只能看到他的日志。

2 个答案:

答案 0 :(得分:0)

您可以在查询中使用where子句。它会是

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

答案 1 :(得分:0)

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

尝试在查询后输入$ con