$conn = mysqli_connect('localhost', 'root', '', 'exam');
mysqli_set_charset($conn, "utf8");//设置编码格式
$sqlX = "SELECT top 10 sum from ncre2c";
?>
4 个解决方案
#1
$conn = mysqli_connect('localhost', 'root', '', 'exam');
mysqli_set_charset($conn, "utf8");//设置编码格式
$_results=mysqli_query($conn, 'SELECT sum from ncre2c order by sum desc LIMIT 10');
if ($_results){
while (!!$row= mysqli_fetch_array($_results, MYSQLI_ASSOC)){
echo '<span>'.$row['sum'].'</span><br/>';
}
}
#2
@hongmei85 老哥 能不能把ID(主键)一块弄出来啊
#3
查询SQL加入ID就行
#4
加上id
$conn = mysqli_connect('localhost', 'root', '', 'exam');
mysqli_set_charset($conn, "utf8");//设置编码格式
$_results=mysqli_query($conn, 'SELECT id,sum from ncre2c order by sum desc LIMIT 10');
if ($_results){
while (!!$row= mysqli_fetch_array($_results, MYSQLI_ASSOC)){
echo '<span>'.$row['id'].':'.$row['sum'].'</span><br/>';
}
}
#1
$conn = mysqli_connect('localhost', 'root', '', 'exam');
mysqli_set_charset($conn, "utf8");//设置编码格式
$_results=mysqli_query($conn, 'SELECT sum from ncre2c order by sum desc LIMIT 10');
if ($_results){
while (!!$row= mysqli_fetch_array($_results, MYSQLI_ASSOC)){
echo '<span>'.$row['sum'].'</span><br/>';
}
}
#2
@hongmei85 老哥 能不能把ID(主键)一块弄出来啊
#3
查询SQL加入ID就行
#4
加上id
$conn = mysqli_connect('localhost', 'root', '', 'exam');
mysqli_set_charset($conn, "utf8");//设置编码格式
$_results=mysqli_query($conn, 'SELECT id,sum from ncre2c order by sum desc LIMIT 10');
if ($_results){
while (!!$row= mysqli_fetch_array($_results, MYSQLI_ASSOC)){
echo '<span>'.$row['id'].':'.$row['sum'].'</span><br/>';
}
}