|
-
Feb 6th, 2003, 07:14 AM
#1
select count(*) value *resolved*
PHP Code:
$countquery="SELECT COUNT(*) FROM guestbook";
$pagecount=mysql_query($countquery);
Now that the query has been executed, how can I access the value of the number returned by the countquery?
I do an echo $pagecount, and it returns to me:
Last edited by mendhak; Feb 7th, 2003 at 12:18 AM.
-
Feb 6th, 2003, 12:25 PM
#2
Stuck in the 80s
I'm not sure, but I do know another way to do it:
Code:
$countquery="SELECT * FROM guestbook";
$pagecount=mysql_num_rows(mysql_query($countquery));
-
Feb 6th, 2003, 12:29 PM
#3
Stuck in the 80s
I just gave this a try, and it works:
Code:
$countquery="SELECT COUNT(*) FROM guestbook";
$pagecount=mysql_query($countquery);
$count = mysql_fetch_row($pagecount);
echo $count[0];
-
Feb 6th, 2003, 04:01 PM
#4
Frenzied Member
most of the time when you do count(*) you do it like so
PHP Code:
$countquery="select count(*) AS total from guestbook
$pagecount=mysql_query($countquery);
$result = mysql_fetch_array($pagecount);
echo $result["total"];
that will echo out the total rows. but in your situation you can't echo out the query becasue you haven't fetched anything yet.
echo mysql_query("SELECT * FROM guestbook");
that will do the samething you have in the first post. it will return resource ID#
-
Feb 6th, 2003, 10:32 PM
#5
Hi, thanks for the responses. They did work, but I was playing around and I used this:
$somethingelse=mysql_result($pagecount,0);
Is this acceptable as well?
-
Feb 6th, 2003, 10:54 PM
#6
Frenzied Member
not really. mysql_reuslts() is slower then anything else and deprecated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|