Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在表中显示所有用户的_Php_Mysql_Database - Fatal编程技术网

Php 在表中显示所有用户的

Php 在表中显示所有用户的,php,mysql,database,Php,Mysql,Database,我想在表中显示所有注册用户。如何设置循环以从中获取所有已注册用户并以html显示。下面的代码是我的html用户表格式: <tr> <td><input type="checkbox" /></td> <td><a href="#">Admin</a></td> <td>4th of May 2010 - 9:31</td> <td> <

我想在表中显示所有注册用户。如何设置循环以从中获取所有已注册用户并以html显示。下面的代码是我的html用户表格式:

<tr>
  <td><input type="checkbox" /></td>
  <td><a href="#">Admin</a></td>
  <td>4th of May 2010 - 9:31</td>
  <td>
    <a href="#"><img src="images/icons/pencil.png" alt="Edit" /></a>
    <a href="#" class="confirmation"><img src="images/icons/cross.png" alt="Delete" /></a><!-- to create a tooltip-style confirmation, just add .confirmation to the <a>-tag -->
  </td>
</tr>

我假设您的表是“用户”

我在表格行中简单显示用户名,您可以根据需要进行修改

 mysql_connect('your_server', 'username', 'password') or die(mysql_error()); 
 mysql_select_db("your_database_name") or die(mysql_error()); 

$query="select * from users";
$result=mysql_query($query);
$arr = array();
echo "<table>";
while($row = mysql_fetch_array($result)){ 
    echo "<tr>".$row['name']."</tr>";
}
echo "</table>";

到目前为止你做了什么?我完成了注册和登录页面,通过这个页面,所有用户都可以注册并成功登录,现在我正在尝试获取所有注册用户的,我不知道如何使用while循环获取所有用户的,以显示上述html格式。您的查询在哪里?能否请您描述我如何设置查询和获取数据。Ayyanar G:-非常非常感谢,当我按照您的代码完成操作时,我真的很兴奋。这是惊人的,工作很好。再次表示感谢欢迎你。。。每次都要提高自己,玩得开心