displaying the results of calculations with php&mysql
| From: | Scott M Wagner | Date: | Sun, 10 Sep 2000 13:17:57 +0000 |
| Subject: | displaying the results of calculations with php&mysql | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-2771@lists.php.net to get a copy of this message | ||
Oops. Here is that file:
<HEAD>
<TITLE>Page Title</TITLE>
</HEAD>
<BODY>
<?php
$db_name = "test_db";
$table_name = "room_3";
$connection = @mysql_connect("localhost", "nevermind", "canttell") or
die("Couldn't connect.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select
database.");
$sql = "
select id_number, name, date, goal_1, goal_2, goal_3, goal_4, wu
from $table_name
where date >= '2000-09-08 and date =< 2000-09-14'
";
$result = @mysql_query($sql,$connection) or die("Couldn't execute
query.");
if ($row = mysql_fetch_array($result)){
echo "$table_name";
echo "<table border=1>\n";
echo
"<tr><td><strong>Id#</strong></td><td><strong>Name</strong></td>
<td><strong>Date</strong></td><td><strong>Goal
1</strong></td><td><strong>Goal 2</strong></td>
<td><strong>Goal 3</strong></td><td><strong>Goal
4</strong></td>
<td><strong>WU</strong></td></tr>\n";
do {
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s
</td><td>%s
</td><td>%s</tr>\n",
$row["id_number"], $row["name"], $row["date"],
$row["goal_1"],
$row["goal_2"], $row["goal_3"],
$row["goal_4"], $row["wu"]);
} while ($row = mysql_fetch_array($result));
echo "</table>\n";
} else {
echo "Sorry no results were found!";
}
?>
</BODY>
</HTML>