Fetch array values outside while loop in PHP

by Ramya 2012-10-11 18:51:16

Fetch array values outside while loop in PHP:

Use the following method in order to get the variable outside the while loop,

$Query = $db->selectQuery("table","id");
$getValue = array();
while($row=mysql_fetch_array($Query, MYSQL_NUM)){
$getValue[] = array('id' => $row[0]);
}
print_r($getValue);


Above code fetches all the ids from resultant query and displays using the print_r();

785
like
0
dislike
0
mail
flag

You must LOGIN to add comments