Sorry if this is terribly basic.
Writing code such as this is easy
Code:
$sql2 = 'SELECT COUNT( DISTINCT `Author` ) FROM `books` LIMIT 0, 100';
but the $64 question is, whats next to make the result show up on a web page? I have this code, please refer to the above code at the bottom of the page
Code:
<?
$dbh=mysql_connect ("localhost", "XXXX", "XXXXX") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("lunar_effort", $dbh);
$sql = ("INSERT INTO `books`(`Book`, `Year`, `Author`, `Genre`, `Number`, `Series`, `Complete`,`Recommendation`, `Status`, `Key`)
VALUES ('$_POST[Book]', '$_POST[Year]', '$_POST[Author]', '$_POST[Genre]', '$_POST[Number]', '$_POST[Series]', '$_POST[Complete]', '$_POST[Recommendation]', '$_POST[Status]', NULL)");
if (!mysql_query($sql,$dbh))
{
die('Error: ' . mysql_error());
}
echo $_POST ["Book"],"<br />";
echo $_POST ["Year"],"<br />";
echo $_POST ["Author"],"<br />";
echo $_POST ["Genre"],"<br />";
echo $_POST ["Number"],"<br />";
echo $_POST ["Series"],"<br />";
echo $_POST ["Complete"],"<br />";
echo $_POST ["Recommendation"],"<br />";
echo $_POST ["Status"],"<br />";
echo "1 record added","<br />";
echo "The number of records is ";
$sql1 = "SELECT * FROM books";
$result = mysql_query($sql1,$dbh);
echo mysql_num_rows($result);
echo "<br />";
echo "The number of Authors is ";
$sql2 = 'SELECT COUNT( DISTINCT `Author` ) FROM `books` LIMIT 0, 100';
$result = mysql_query($sql2,$dbh);
echo mysql_num_fields($result);
mysql_close($dbh);
?>
Everything works perfectly till I get to this code
Code:
echo "The number of Authors is ";
$sql2 = 'SELECT COUNT( DISTINCT `Author` ) FROM `books` LIMIT 0, 100';
$result = mysql_query($sql2,$dbh);
echo mysql_num_fields($result);
At the $result part, I have no clue what I am doing to make it appear when called. Can anyone point at a tutorial that isnt just about how to write the Select Count part and how to echo the results?
(or help with the code as to what should be there?)