我试图显示当前登录用户的用户名
该表如下所示: 表名:system_users , u_userid - 获取 id u_username - 获取用户名
我想显示 u_username ......它现在可以工作,但它显示所有用户。
这是代码,它显示所有用户,我只想显示登录的用户
<?php
$connection = mysql_connect('localhost', 'SQLUSER', 'SQLPW'); //The Blank
string is the password
mysql_select_db('comenzi.highmob');
$query = "SELECT * FROM system_users"; //You don't need a ; like you do in SQL
$result = mysql_query($query);
echo "<table>"; // start a table tag in the HTML
while($row = mysql_fetch_array($result)){ //Creates a loop to loop through
results
echo "<tr><td>" . $row['u_username'] . "</td></tr>"; //$row['index'] the index
here is a field name
}
echo "</table>"; //Close the table in HTML
mysql_close(); //Make sure to close out the database connection
?>
你必须使用 where 条件
例如
$query = "SELECT * FROM system_users WHERE UserID = 2"
在您的情况下,您可以从会话中获取用户 ID
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句