请帮忙看一下这段php代码哪里出错了,为什么显示不了结果
代码如下:<html><head><title>firstpage</title></head><body><h1>firstpagesearchresults</h1>...
代码如下:
<html>
<head>
<title>firstpage</title>
</head>
<body>
<h1>firstpage search results</h1>
<?php
@ $db=new mysqli('localhost','root','87898484','studentscore');
$sql="select * from studentscore order by maths asc limit 5";
$result=mysql_query($sql);
while ($myrow=mysql_fetch_assoc($result))
{
echo $myrow['id'];
echo $myrow['name'];
echo $myrow['maths'];
echo $myrow['chinese'];
echo "<br/>";
}
?>
</body>
</html> 展开
<html>
<head>
<title>firstpage</title>
</head>
<body>
<h1>firstpage search results</h1>
<?php
@ $db=new mysqli('localhost','root','87898484','studentscore');
$sql="select * from studentscore order by maths asc limit 5";
$result=mysql_query($sql);
while ($myrow=mysql_fetch_assoc($result))
{
echo $myrow['id'];
echo $myrow['name'];
echo $myrow['maths'];
echo $myrow['chinese'];
echo "<br/>";
}
?>
</body>
</html> 展开
1个回答
展开全部
<html>
<head>
<title>firstpage</title>
</head>
<body>
<h1>firstpage search results</h1>
<?php
$db=mysql_connect('localhost','root','87898484');//这里改了
mysql_select_db("数据库名");//这里加的,自己改一下数据库名
$sql="select * from studentscore order by maths asc limit 5";//这里的字段名要确定一下正确否
$result=mysql_query($sql);
while ($myrow=mysql_fetch_assoc($result))
{
echo $myrow['id'];
echo $myrow['name'];
echo $myrow['maths'];
echo $myrow['chinese'];
echo "<br/>";
}
?>
</body>
</html>
<head>
<title>firstpage</title>
</head>
<body>
<h1>firstpage search results</h1>
<?php
$db=mysql_connect('localhost','root','87898484');//这里改了
mysql_select_db("数据库名");//这里加的,自己改一下数据库名
$sql="select * from studentscore order by maths asc limit 5";//这里的字段名要确定一下正确否
$result=mysql_query($sql);
while ($myrow=mysql_fetch_assoc($result))
{
echo $myrow['id'];
echo $myrow['name'];
echo $myrow['maths'];
echo $myrow['chinese'];
echo "<br/>";
}
?>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询