
November 27th, 2002, 01:10 PM
|
|
Contributing User
|
|
Join Date: Apr 2002
Location: Anchorage
Posts: 118
Time spent in forums: < 1 sec
Reputation Power: 7
|
|
|
Counting total in column ...problem
I've been working with this little problem for some time now...here is as close as I've come:
PHP Code:
<?php
$db_name = "aqua_books";
$table_name = "bookinput";
$quantity = "quantity";
$connection = @mysql_connect("localhost", "user", "password") or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());
$query = mysql_query("SELECT COUNT($quantity) FROM $table_name");
$rows = mysql_result($query, 0, 0);
echo "<strong>" .$rows. "</strong>";
?>
This only prints "3" since there are three book titles in the database.
I am looking for the number of books total (quantity) the column "quantity" is an INT with currently 22 total books. One cell has 20 books, all with same title...
Any suggestions?
Thanks for everyones help.
__________________
bow wow!
|