Re: mysql_num_rows
| From: | DL Neil | Date: | Mon, 07 Jan 2002 21:09:34 +0000 |
| Subject: | Re: mysql_num_rows | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-15461@lists.php.net to get a copy of this message | ||
Gurhan,
The first rule with all of these problems is to insert error-checking statements. There are two
types: firstly
the MySQL function set includes error number and error (msg) text facilities; and secondly the
addition of
'debug' echo statements, eg to be absolutely sure what $query looks like before it gets
fed to MySQL.
The other advice is to copy the $query text into a MySQL command line or an administrative package,
eg
MySQL-Front, to test if it works in 'native' mode (so then you can work out if the source
of the problem is PHP
or MySQL code).
Regards,
=dn
----- Original Message -----
From: "Gurhan Ozen" <c-gurhan.ozen@wcom.com>
To: "Richard S. Crawford" <rscrawford@mossroot.com>
Cc: <php-db@lists.php.net>
Sent: 06 January 2002 20:42
Subject: RE: [PHP-DB] mysql_num_rows
hmm that's an idea... I stil don't get why mysql_num_rows wouldn't work with
WHERE clause but i will try to do a workaround with what you said below.
Although it will be a little extra coding I guess I don't have any other
choice:)
Thank you very much for your help:)
Gurhan
-----Original Message-----
From: Richard S. Crawford [mailto:rscrawford@mossroot.com]
Sent: Sunday, January 06, 2002 3:34 PM
To: Gurhan Ozen; php-db@lists.php.net
Subject: RE: [PHP-DB] mysql_num_rows
Hm, if the result you want is the number of distinct nodeid values, why not
use a query like this:
"select count(distinct(nodeid)) as nodecount from books where bookid =
$bookid";
Then the number of nodeid's is stored in nodecount.
You might also want to look into the GROUP BY clause. That might give you
a better handle on what you want to do.
At 12:09 PM 1/6/2002, Gurhan Ozen wrote:
>I am pretty sure that the query is correct. here is the actual query:
> $query="select distinct(nodeid), nodename from books
where
>bookid=$bookid";
> $result=mysql_query($query);
> $num_results=mysql_num_rows($result);
>
> I have loaded a book into the tabel called "books". I have gave each
>section a nodeid and each book a bookid. SO i wanted to get number of
>distinct nodeid's (i.e. sections) in the book so that i could use a for
loop
>to display all of them and an inner for loop to display each page under
each
>section.
> The funny thing is that if i write the same query without "where
>bookid=$bookid" then the mysql_num_rows works but with where statement it
>doesn't.
> By the way the web hoster i am using has PHP Version 4.0.6 .
> Thanks.
>Gurhan
Sliante,
Richard S. Crawford
http://www.mossroot.com
AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford
MSN: underpope@hotmail.com
"It is only with the heart that we see rightly; what is essential is
invisible to the eye." --Antoine de Saint Exupéry
"Push the button, Max!"
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
For additional commands, e-mail: php-db-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net