Re: MYSQL Question

From: Date: Wed, 28 Jun 2000 15:37:15 +0000
Subject: Re: MYSQL Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-3578@lists.php.net to get a copy of this message
> 1. Is there sometype of MYSQL command or PHP3 function to get 1 row > and then get the following row after that, and so on...until the last row > and then stop editing. If you SELECT all the rows in your query (i.e. no WHERE clause), then the result set returned from mysql_query() can be "walked-through": $query = "/* Your query here */"; $results = mysql_query ($query); while ($row = mysql_fetch_array ($results)) { // Each row is returned individually in the array $row // Access fields as if each field were an element in an array ... } > 2. Is there some function that tells how many records are in a table? The number of rows can be determined from the above result set (i.e. having SELECTed every row in the table) with mysql_num_rows(): $numRows = mysql_num_rows ($results); [Disclaimer: There may be a better way to do this, but it's the best way I can think of using just the basic MySQL functions and simple queries.] Hope this helps. Stephen. -- Computer Terms: Programmer - A red-eyed, mumbling mammal capable of conversing with inanimate objects. Stephen Hui, ARL:UT, Austin, TX

« previous php.general (#3578) next »