Problem Querying Multiple Rows

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
nbasso713
Forum Commoner
Posts: 29
Joined: Fri Nov 04, 2011 7:51 am

Problem Querying Multiple Rows

Post by nbasso713 »

All I'm trying to do is create an array with all the id's that have a value of 0 in the status column of the table.

Code: Select all

$query = mysql_query("SELECT `tempID` FROM `pending` WHERE `status` = 0");
$status = mysql_fetch_array($query);
This codes has only been returning a single row any ideas?
nbasso713
Forum Commoner
Posts: 29
Joined: Fri Nov 04, 2011 7:51 am

Re: Problem Querying Multiple Rows

Post by nbasso713 »

SOLVED

Created a while loop.

Code: Select all

while ($row = mysql_fetch_array($query, MYSQL_NUM)) {
     $status[$i] =  $row[0];
     $i++;
} 
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Problem Querying Multiple Rows

Post by VladSun »

You may skip $i :

Code: Select all

while ($row = mysql_fetch_array($query, MYSQL_NUM)) {
  $status[] =  $row[0];
}
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply