ok, first your query is wrong.
$sql2 = 'SELECT COUNT( DISTINCT `Author` ) FROM `books` LIMIT 0, 100';
should be
$sql2 = "SELECT COUNT(DISTINCT(`Author`)) FROM `books`";
No point in using a LIMIT clause when only a single row is returned due to the select clause.
Next, you need to go and read the documentation on the MySQL functions, the example you gave isnt even close. I understand how you got there, but make sure to read the docs.
Here is the correct way to do it:
$sql2 = "SELECT COUNT(DISTINCT(`Author`)) FROM `books`";
$result = mysql_query($sql2); <-- Dont need the DB connection unless you have more than one.
$count = mysql_fetch_row($result);
print("The number of Authors is " . $count); <-- echo is fine too, I just the implicit print, a throwback to Jython/JAVA/Perl
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
|