maybe you can try this :
$query="select COUNT(*) as total from january08_practices where
Practices = 'yes'";
$rt=mysql_query($query);
// If query success, print out the result
if($rt){
echo " Command is successful ";
$result = mysql_fetch_assoc($rt);
echo $result['total'];
}
// else, show the error
else {
echo "Command is not successful ";
print mysql_error();
}
On Mon, 2008-01-07 at 10:49 -0600, Grant Harrington wrote:
> New print question:
>
> <?php
> $db_host = 'myhost';
> $db_user = 'user';
> $db_pwd = 'password';
>
> $database = 'survey';
> $table = 'january08_practices';
>
> if (!mysql_connect($db_host, $db_user, $db_pwd))
> die("Can't connect to database");
>
> if (!mysql_select_db($database))
> die("Can't select database");
>
> $query="select COUNT(*) from january08_practices
> where Practices = 'yes'";
> $rt=mysql_query($query);
> if($rt){echo " Command is successful ";}
> else {echo "Command is not successful ";}
> print mysql_error();
> print_r ($rt);
> ?>
>
> The results I get on the webpage are:
>
> Command is successful Resource id #2
>
> I want the value to be "30" which is the number of "yes" responses
> and when I run the query in CocoaMySQL, select COUNT(*) from
> january08_practices
> where Practices = 'yes'; I get an answer of 30.
>
> How do I print "30" on my webpage?
>
> Thanks,
> Grant
>
> On Jan 7, 2008, at 8:57 AM, Allen D. Tate wrote:
>
> > Good deal. I think that there are security issues with the echo
> > command
> > so this is the better solution anyway. :)
>
> [Non-text portions of this message have been removed]
>
>
>
>
>