Reputation: 95
Hi users of Stack Overflow,
I am facing a issue where my SQL data won't display properly and I am not sure on how to fix this problem. I only see the print section with no appropriate data.
<!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>
Upvotes: 0
Views: 1473
Reputation: 1216
while ($row = mysql_fetch_assoc($result)) {
$symbol= $row['Symbol'];
$date= $row['Date'];
$avgprice= $row['avg_price'];
$var4 = $row['field4']
."<br>";
echo "<tr>
<td >".$symbol."</td>
<td >".$date."</td>
<td >".$avgprice."</td>
<td >".$var4."</td>
</tr>";
Upvotes: 1
Reputation: 884
try something like this
print "<div>".$row[id]. $row[module]. $row[day]. $row[start]."</div>\n";
Upvotes: 0
Reputation: 705
Try This
while ($row = mysql_fetch_array($result)){
echo "<div>".$row['id'];
echo $row['module'];
echo $row['day'];
echo $row['start'];
echo "</div>";
}
Instead of: print "$row[id] $row[module] $row[day] $row[start]\n";
Upvotes: 0
Reputation: 2138
Use:
print "<div>{$row['id']} {$row['module']} {$row['day']} {$row['start']}</div>\n";
Instead of:
print "<div>$row[id] $row[module] $row[day] $row[start]</div>\n";
Upvotes: 1