PHP读取MYsql数据后重新排序问题
$con=mysql_connect("localhost","root","");if(!$con){die('数据库连接失败:'.mysql_error());}el...
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('数据库连接失败: ' . mysql_error());
}
else
{
mysql_query("SET NAMES GB2312");
mysql_query("set character_set_client=GB2312");
mysql_query("set character_set_results=GB2312");
mysql_select_db("db", $con);
$result = mysql_query("SELECT * FROM player_names");
//在表格中输出显示结果
echo "<table border='1'>
<tr>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['unique_id'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['gold'] . "</td>";
echo "<td>" . $row['bankgold'] . "</td>";
echo "<td>" . $row['last_used_time'] . "</td>";
echo "<td>" . $row['health'] . "</td>";
echo "</tr>";
}
echo "</table>";
按表格输出后 排序是按照数据库原来的顺序排序的 我想按照bankgold的大小值进行从大到小的降幂排序 希望高人解答 万分感谢 展开
if (!$con)
{
die('数据库连接失败: ' . mysql_error());
}
else
{
mysql_query("SET NAMES GB2312");
mysql_query("set character_set_client=GB2312");
mysql_query("set character_set_results=GB2312");
mysql_select_db("db", $con);
$result = mysql_query("SELECT * FROM player_names");
//在表格中输出显示结果
echo "<table border='1'>
<tr>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['unique_id'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['gold'] . "</td>";
echo "<td>" . $row['bankgold'] . "</td>";
echo "<td>" . $row['last_used_time'] . "</td>";
echo "<td>" . $row['health'] . "</td>";
echo "</tr>";
}
echo "</table>";
按表格输出后 排序是按照数据库原来的顺序排序的 我想按照bankgold的大小值进行从大到小的降幂排序 希望高人解答 万分感谢 展开
1个回答
展开全部
SELECT * FROM player_names这个sql变成
SELECT * FROM player_names ORDEER BY bankgold DESC
SELECT * FROM player_names ORDEER BY bankgold DESC
追问
谢谢你的回答,但是我刚才修改了下发现错误Call Stack 调用堆栈Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\tshvictor\index.php on line 36
追答
抱歉 多打了个e
SELECT * FROM player_names ORDER BY bankgold DESC
这回对了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询