Re: [PHP]Getting rows in a db...

2001-08-01 Thread David Robley

On Thu,  2 Aug 2001 14:57, Chris Cocuzzo wrote:
 hey-

 if I do this:

 $query = SELECT user FROM table WHERE cat='band';
 $result = mysql_query($query,$conn);
 $rows = mysql_num_rows($result);

 will I get something back from the $rows variable, or am I using the
 mysql_num_rows() function incorrectly. What I'm trying to do is get the
 number of rows returned as a result of that specific sql statement and
 query.

 thanks
 chris

That should show the number of rows returned by the query, providing 
there is a successful result. Try it!

-- 
David Robley  Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES  Flinders University, SOUTH AUSTRALIA  

   Shotgun wedding: a case of wife or death.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP]Getting rows in a db...

2001-08-01 Thread Richard Lynch

Yes, if your $conn is valid in the first place, and your SQL is valid.

I think 'table' is a reserved word, so as-is, it won't work.

Add some error-checking code to see what MySQL is saying about your
connection and SQL.

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
- Original Message -
From: Chris Cocuzzo [EMAIL PROTECTED]
Newsgroups: php.general
To: [EMAIL PROTECTED]
Sent: Thursday, August 02, 2001 12:27 AM
Subject: [PHP]Getting rows in a db...


 hey-

 if I do this:

 $query = SELECT user FROM table WHERE cat='band';
 $result = mysql_query($query,$conn);
 $rows = mysql_num_rows($result);

 will I get something back from the $rows variable, or am I using the
 mysql_num_rows() function incorrectly. What I'm trying to do is get the
 number of rows returned as a result of that specific sql statement and
 query.

 thanks
 chris



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP]Getting rows in a db...

2001-08-01 Thread Lawrence . Sheed

Bear in mind that you don't want to be doing queries like that generally.

Use count(*) to get the number of rows - using mysql_num_rows is slower.

eg
$query=select count(*) from tablename where cat='band';
$result = mysql_query($query,$conn);

etc.


-Original Message-
From: David Robley [mailto:[EMAIL PROTECTED]]
Sent: August 2, 2001 2:13 PM
To: Chris Cocuzzo; [EMAIL PROTECTED]
Subject: Re: [PHP]Getting rows in a db...


On Thu,  2 Aug 2001 14:57, Chris Cocuzzo wrote:
 hey-

 if I do this:

 $query = SELECT user FROM table WHERE cat='band';
 $result = mysql_query($query,$conn);
 $rows = mysql_num_rows($result);

 will I get something back from the $rows variable, or am I using the
 mysql_num_rows() function incorrectly. What I'm trying to do is get the
 number of rows returned as a result of that specific sql statement and
 query.

 thanks
 chris

That should show the number of rows returned by the query, providing 
there is a successful result. Try it!

-- 
David Robley  Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES  Flinders University, SOUTH AUSTRALIA  

   Shotgun wedding: a case of wife or death.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]