A
Anonymous
Guest
I was reading about the count function at this web site.
http://www.webdevelopersnotes.com/tutorials/sql/20.php3
I have a list of books and the date that I read them. I would like to give a summary of how many books, I read for each year.
Here is the PHP code that I wrote. It never gets past the query, stating "Couldn't execute Query." What am I doing wrong?
<?php
$user="cheng_rob";
$host="localhost";
$user="chengrob_rob";
$password="";
$database = "chengrob_book";
$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database)
or die ("Couldn't select database");
$query = "SELECT Year(Rob), COUNT(*) as Number FROM book;
$result = mysql_query($query)
or die ("Couldn't execute query.");
/* Display results in a table */
echo "<center><h1>Results</h1></center>";
echo "<center><table cellPadding=2>";
echo "<tr><td><b>Year</b></td><td><b>Books Count</b></td></tr>";
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "<tr><td>$Rob</td>";
echo "<td>$Number</td>";
}
echo "</table>\n";
?>
http://www.webdevelopersnotes.com/tutorials/sql/20.php3
I have a list of books and the date that I read them. I would like to give a summary of how many books, I read for each year.
Here is the PHP code that I wrote. It never gets past the query, stating "Couldn't execute Query." What am I doing wrong?
<?php
$user="cheng_rob";
$host="localhost";
$user="chengrob_rob";
$password="";
$database = "chengrob_book";
$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database)
or die ("Couldn't select database");
$query = "SELECT Year(Rob), COUNT(*) as Number FROM book;
$result = mysql_query($query)
or die ("Couldn't execute query.");
/* Display results in a table */
echo "<center><h1>Results</h1></center>";
echo "<center><table cellPadding=2>";
echo "<tr><td><b>Year</b></td><td><b>Books Count</b></td></tr>";
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "<tr><td>$Rob</td>";
echo "<td>$Number</td>";
}
echo "</table>\n";
?>