dongliang2005 2014-01-28 14:51
浏览 10

too long

I am trying to display the best player on a page and using this php code to get the result

<?php
//include database connection
include 'db_connect.php';
//query all records from the database
$query = "select cwins, close, name, id
from cseason ORDER BY cwins DESC LIMIT 1";
//execute the query
$result = $mysqli->query( $query );
//get number of rows returned
$num_results = $result->num_rows;
//this will link us to our add.php to create new record
if( $num_results > 0){
//loop to show each records
while( $row = $result->fetch_assoc() ){
//extract row
//this will make $row['firstname'] to
//just $firstname only
extract($row);
//creating new table row per record
echo "<tr>";
echo "<td>{$name}</td>";
echo '<td align="center">';
if (($cwins + $close) != 0) $rate = (($cwins / ($cwins + $close)) * 100);
else $rate = 0;
if ($rate > 70) {
echo "<span class='badge badge-success'>";
print round ($rate);
} elseif ($rate < 40) {
echo "<span class='badge badge-important'>";
print round ($rate);
}
else {
echo "<span class='badge badge-warning'>";
print round ($rate);
}
echo '</span>';
echo '</td>';
}
echo "</tr></table>";//end table
}else{
//if database table is empty
echo "No records found.";
}
//disconnect from database
$result->free();
$mysqli->close();

?>     

Here is the data in cseason

[     id    ] [   name    ] [   cwins     ] [   close   ]
- - - - - - - - - - - - - - - - - - - - - - - - - - -- - -
[     1    ]  [   rick    ] [      11     ] [       1   ]
[     2    ]  [   dave    ] [      6      ] [       6   ]
[     3    ]  [   neil    ] [      7      ] [       5   ]
[     4    ]  [   simon   ] [      3      ] [       9   ]

It currently displays Neil which is wrong.

I ran the code directly in phpmyadmin and it comes up with the same answer.

Where have I gone or what have I over seen?


Ok i have gone into phpMYadmin to investigate there and found when i try to reorder the column 'cwins' the row neil still goes to the top...

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
    • ¥20 关于URL获取的参数,无法执行二选一查询
    • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
    • ¥15 marlin编译错误,如何解决?
    • ¥15 有偿四位数,节约算法和扫描算法
    • ¥15 VUE项目怎么运行,系统打不开
    • ¥50 pointpillars等目标检测算法怎么融合注意力机制
    • ¥20 Vs code Mac系统 PHP Debug调试环境配置
    • ¥60 大一项目课,微信小程序
    • ¥15 求视频摘要youtube和ovp数据集