At 12:40 AM -0500 2/22/11, Gary wrote:
Can someone tell me why this is not working? I do not get an error message,
the results are called and echo'd to screen, the count does not work, I get
a 0 for a result...
$result = mysql_query("SELECT * FROM `counties` WHERE name = 'checked'") or
die(mysql_error());
if ( isset($_POST['submit']) ) {
for($i=1; $i<=$_POST['counties']; $i++) {
if ( isset($_POST["county$i"] ) ) {
echo "You have chosen ". $_POST["county$i"]." <br/>";
}
}
}
$county_total=mysql_num_rows($result);
while($row = mysql_fetch_array($result))
{$i++;
echo $row['name'];
}
$county_total=mysql_num_rows($result);
echo "$county_total";
echo 'You Have ' . "$county_total" . ' Counties ';
?>
Gary:
With regard of the count thing, why not let MySQL do the work?
$query = "SELECT COUNT(*) AS total FROM 'counties' WHERE name = 'checked' ";
$result = mysql_query($query) or die(mysql_error());
$total = $rowcount['total'];
Cheers,
tedd
--
-------
http://sperling.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php