3 items in table, mysql_fetch_array shows only 1

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

3 items in table, mysql_fetch_array shows only 1

Post by $var »

here is a BASIC php mysql query running in a function:

Code: Select all

		$select = mysql_query("SELECT price, quantity FROM cart_items WHERE (cid = '1')");	
		$row = mysql_fetch_array($select) or die (mysql_error());				
		var_dump($row);
Here is the table, the first field is the cid:

Code: Select all

	1 	59530N34022 	94 	2
	1 	15123N21999 	83 	2
	1 	13723N48311 	110 	2
My var_dump shows only the values of the 1st row.

The other 2 rows that follow the same condition are not appearing in the array.
Any clue as to why this limitation would be happening?

It's oh so frustrating.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: 3 items in table, mysql_fetch_array shows only 1

Post by AbraCadaver »

Read the manual. mysql_fetch_array() fetches 1 row.

Code: Select all

while($row = mysql_fetch_array($select)) {
   var_dump($row);
}
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply