<?php
@mysql_connect("127.0.0.1","root","1s#876#$#$%Ss2")or die; //链接数据库
@mysql_select_db("gamedb")or die; //选择数据库
@mysql_query("set names 'utf8'");
$query = @mysql_query("select * from role_data")or die; //查询‘yonghu’表中的所有记录
echo "<table border=1><tr align=center><th>ID</th><th>角色</th><th>对应帐号</th><th>等级</th><th>上线</th><th>下线</th><th>钻石</th></tr>";
$n=0;
while ($row = mysql_fetch_array($query)) //遍历‘yonghu’表中的数据,并形成数组
{
$role_id = $row['role_id']; //使用键获取数组中对应的值
$role_name = $row['role_name'];
$account_id = $row['account_id'];
$level = $row['level'];
$login_time = $row['login_time'];
$logout_time = $row['logout_time'];
$bag_yuanbao = $row['bag_yuanbao'];
echo "<tr>";
echo "<td>{$role_id}</td>"; //按照数据表的列在表格里输出对应数据
echo "<td>{$role_name}</td>";
echo "<td>{$account_id}</td>";
echo "<td>{$level}</td>";
echo "<td>{$login_time}</td>";
echo "<td>{$logout_time}</td>";
echo "<td>{$bag_yuanbao}</td>";
echo "</tr>";
$n++;
/* if($n>14){
return;
}*/
}
echo "<table>";
?>
如何让数据按时间或者ID排序啊
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- msgwxy 2018-03-22 05:16关注
你好,你得在 SQL语句中,加上排序 ,如 select * from role_data order by login_time 这是按时间排序 如 select * from role_data order by role_id 这是按ID排序
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 2无用