Ok, I can't figure out how to make my "select sum(runtime) from list"
query work properly. At the bottom is the entire page. I've tried a
few different things, but can't figure out how I'm SUPPOSED to set this
up.
Here is what I think are the relevant lines:
$dvd_time_query = "select sum(runtime) from list";
$dvd_time_result = mysql_query($dvd_time_query);
#$dvd_time_display = mysql_fetch_array($dvd_time_query);
#echo "<td class=m><font size =
-1><b>".($dvd_time_display[count])."</b></td>";
echo "<td class=m><font size = -1><b>".$dvd_time_result."</b></td>";
Notice I've tried a few things, that I currently have commented out. I
think I need a while loop in here somewhere from what I've read, but I
haven't been able to make sense of the manual or any other help pages
I've found.
Any help would be greatly appreciated.
Thanks,
Chip
<html>
<head>
<title>Our DVD's</title>
<link rel="stylesheet" href="dvd.css" />
<style type="text/css"></style>
</head>
<body link=white vlink=white alink=white>
<?
@$db = mysql_pconnect("localhost","username","password");
if (!$db)
{
echo "Error: Could not connect to the database. Please try
again later.";
exit;
}
mysql_select_db("dvds");
$query = "select * from list order by title";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
$dvd_time_query = "select sum(runtime) from list";
$dvd_time_result = mysql_query($dvd_time_query);
#$dvd_time_display = mysql_fetch_array($dvd_time_query);
echo "<table cols=5 align=center border=0 cellspacing=2 cellpadding=2
bgcolor=#ffffff>";
echo "<thead style='display:table-header-group'>";
echo "<tr bgcolor=#505050>";
echo "<td class =m valign=bottom><font size = -1 color =
white><A HREF=''><b>Title</A></td>";
echo "<td class =m valign=bottom><font size = -1 color =
white><A HREF='genre.dvds.php'><b>Genre</a></td>";
echo "<td class =m valign=bottom><font size = -1 color =
white><A HREF='rating.dvds.php'><b>Rating</A></td>";
echo "<td class =m valign=bottom><font size = -1 color =
white><A HREF='runtime.dvds.php'><b>Runtime</A></td>";
echo "<td class =m valign=bottom><font size = -1 color =
white><b>More Info</td>";
echo "</tr>";
echo "</thead>";
echo "<tbody style='display:table-row-group'>";
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
echo "<tr bgcolor=#e0e0e0 valign=top>";
echo "<td><font size = -1>";
echo htmlspecialchars( stripslashes($row["title"]));
echo "</td>";
echo "<td><font size = -1>";
echo htmlspecialchars( stripslashes($row["genre"]));
echo "</td>";
echo "<td><font size = -1>";
echo htmlspecialchars( stripslashes($row["rating"]));
echo "</td>";
echo "<td class=info align = right><font size = -1>";
echo htmlspecialchars( stripslashes($row["runtime"]));
echo "</td>";
echo "<td><font size = -1><center>";
echo " <A HREF='";
echo htmlspecialchars( stripslashes($row["info"]));
echo "' target='_blank' class=info>More Info</A>";
echo " ";
echo "</td><center>";
echo "</tr>";
}
echo "<td class=m><font size = -1><b>Total Runtime:</b></td>";
echo "<td class=m><font size = -1> </td>";
echo "<td class=m><font size = -1> </td>";
#echo "<td class=m><font size =
-1><b>".($dvd_time_display[count])."</b></td>";
echo "<td class=m><font size = -1><b>".$dvd_time_result."</b></td>";
echo "<td class=m><font size = -1> </td>";
echo "</table>";
echo "Total Number of DVD's in Dabatase: ".$num_results."";
?>
</body>
</html>
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php