php从mysql中取数据显示出错

<?php
header("content-type:text/html;charset=utf-8");
$conn=mysql_connect('localhost','root','root') or die('数据库连接失败!');
mysql_select_db('student');
mysql_query('set names utf8');
$rs=mysql_query("select * from stu_grade");

echo "<table width='900' border='1' bordercolor='blue'>";
echo "<tr>";
echo "<th>ID</th>";
echo "<th>姓名</th>";
echo "<th>分数</th>";
echo "</tr>";

while ($row=mysql_fetch_row($rs)) {
    echo "<tr>";
    echo "<td>{$row[0]}<td>";    
    echo "<td>{$row[1]}<td>";
    echo "<td>{$row[2]}<td>";
    echo "</tr>";
}
echo "</table>";

?>

https://img2.mukewang.com/5c8f397a0001f57b08000148.jpg

一只名叫tom的猫
浏览 443回答 1
1回答

慕姐4208626

echo "<tr>";echo "<td>{$row[0]}</td>"; echo "<td>{$row[1]}</td>";echo "<td>{$row[2]}</td>";echo "</tr>"; 改成这样. 建议直接学习mysqli或者pdo,
打开App,查看更多内容
随时随地看视频慕课网APP