Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 15th, 2004, 02:44 PM
Authorized User
 
Join Date: Jun 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default PHP - Db mysql count

Hello all,

I am trying to do a simple count of how many individuals have agreed to the terms on a form and how many have disagreed now I use the count function via query but I keep on receiving back this info on the php page

"Yes":( Resource id #3)
"No":( Resource id #4)

the query is as such: $res = mysql_query("SELECT count(list) FROM check_list WHERE list='Yes'");

IT seems to work but Its not providing me with the appropriate number of records that have individuals agreeing to the form...

Please advice?
 
Old July 15th, 2004, 02:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You need to extract the value from the resource. $res is an array, even when there's only one array member: that's just how resultsets get returned. So $res actually represents

$count => 'your answer'

...and not 'your answer'. Try something like:

$answer = mysql_result($res,0,0);

Dan
 
Old July 15th, 2004, 02:59 PM
Authorized User
 
Join Date: Jun 2003
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dan, Thanks a bunch... it works like a charm...

dungey





Similar Threads
Thread Thread Starter Forum Replies Last Post
connect to mysql db from php 5 crmpicco PHP Databases 1 September 26th, 2007 05:14 PM
begin php & mysql - chapter 12, user_form.php jon_stubber Beginning PHP 1 March 9th, 2006 10:57 AM
Storing PHP Session data in a MySQL db? CFerthorney PHP Databases 1 May 10th, 2004 08:33 AM
PHP count and question check? Ashleek007 PHP How-To 0 May 4th, 2004 07:36 AM
How to count Records using acess as backend in Php manjiri PHP Databases 1 December 23rd, 2003 04:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.