Fw: newbie query query
| From: | Scott M Wagner | Date: | Sat, 16 Sep 2000 19:57:08 +0000 |
| Subject: | Fw: newbie query query | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-2928@lists.php.net to get a copy of this message | ||
--------- Forwarded message ----------
From: Scott M Wagner <thegildedpage@juno.com>
To: mysql@lists.mysql.com
Date: Sat, 16 Sep 2000 10:33:36 -0400
Subject: newbie query query
Message-ID: <20000916.103337.-415741.0.thegildedpage@juno.com>
Hello!
Can anyone tell me why the 'sum(goal_1) as Total' command will not
execute in the following php script? Thanks very much.
<HTML>
<HEAD>
<TITLE>Page Title</TITLE>
</HEAD>
<BODY>
<?php
$db_name = "testtrack_db";
$table_name = "room_3";
$connection = @mysql_connect("localhost", "blahblah", "xxxxx") or
die("Couldn't connect.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select
database.");
$sql = "
select id_number, date, goal_1, goal_2, goal_3, goal_4, wu,
sum(goal_1)as Total
from $table_name
where date >= '2000-09-08' and date <= '2000-09-14'
order by date
";
$result = @mysql_query($sql,$connection) or die("Couldn't execute
query.");
if ($row = mysql_fetch_array($result)){
echo "<strong>Joe Student</strong>";
echo "<table border=1>\n";
echo "<tr><td><strong>Id#</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><td><strong>Daily%</strong></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["date"], $row["goal_1"],
$row["goal_2"],
$row["goal_3"],
$row["goal_4"], $row["wu"], $row["Daily"]);
} while ($row = mysql_fetch_array($result));
echo "</table>\n";
} else {
echo "Sorry no results were found!";
}
?>
</BODY>
</HTML>
--
---------------------------------------------------------------------
Please check "http://www.mysql.com/documentation/manual.php"
before
posting. To request this thread, e-mail mysql-thread50804@lists.mysql.com
To unsubscribe, send a message to:
<mysql-unsubscribe-thegildedpage=juno.com@lists.mysql.com>
If you have a broken mail client that cannot send a message to
the above address (Microsoft Outlook), you can use:
http://lists.mysql.com/php/unsubscribe.php