嗨 Stack Overflow 的用户,
我遇到了一个问题,我的 SQL 数据无法正确显示,我不确定如何解决这个问题。我只看到没有适当数据的打印部分。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="css/default.css" type="text/css" />
<link rel="stylesheet" href="css/timetable.css" type="text/css" />
<title>Timetable Information</title>
</head>
<body>
<div id="header"></div>
<ul id="NavigationList">
<li><a href="Index.php">Index</a></li>
<li><a href="ModuleInfo.php">Module Info</a></li>
<li><a href="ModuleSearch.php">Module Search</a></li>
<li><a href="Timetable.php">Timetable Search</a></li>
</ul>
<p>
<p>Please select a school from the drop-down list.</p>
<?php
require('json.php');
error_reporting(E_ALL);
$connection = mysql_connect('localhost', 'root','') or
die("Could not connect: " . mysql_error());
mysql_select_db("timetable") or die("No such database");
$sql = sprintf("
SELECT id,day,start,module
FROM event JOIN teaches ON (event.id=teaches.event)
WHERE staff='%s'", mysql_real_escape_string($_REQUEST['staff']));
$result = mysql_query($sql)
or die(mysql_error());
while ($row = mysql_fetch_array($result)){
print "<div>$row[id] $row[module] $row[day] $row[start]</div>\n";
}
?>
</p>
<div id="Footer">
<p id="FooterText">Copyright © 2012 .<br />All rights reserved.</p>
</div>
</body>
</html>