mysql_query
| From: | Peter | Date: | Sun, 14 Oct 2001 17:22:05 +0000 |
| Subject: | mysql_query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-71037@lists.php.net to get a copy of this message | ||
Hi,
I was following a script in PHP Essentials book and I had trouble
understanding the syntax of particular line. The lines went like this:
$connection = mysql_connect("localhost","username","password") or die
("Couldn't connect to database.");
$db =mysql_select_db("micromotor", $connection) or die ("Couldn't select
database.");
$sql_count1 = "SELECT COUNT(modelno) from products where category =\"camera\"";
$sql_result_count1 = mysql_query($sql_count1, $connection) or die
("Couldn't get count!");
$count1 = mysql_result($sql_result_count1,0,"count(modelno)");
echo $count1
I got the right answer, which was 2 because I had two camera products in
my database. But I was wondering on the second last line which reads:
$count1 = mysql_result($sql_result_count1,0,"count(modelno)");
Why do I need a "0" and the "count(modelno)" function again at the very
end?
All I know that is without it, I can't get the right answer.
Thanks
Peter