suppose i have a query
$array = array();
$sql = mysql_query("SELECT * FROM table");
while($row=mysql_fetch_array($sql)){
$data = $row['data'];
}
$array = $data;
Now how can i get that each $data values out of while in an array() i.e $array
by adding each $row to array $data
for reference: http://php.net/types.array
Note that there is no such a thing as "while() array". There are just arrays only.
You need to save each iteration object into a "new" object, so your code will look just like:
$array = array();
$sql = mysql_query("SELECT * FROM table");
while($row=mysql_fetch_array($sql)){
$array[] = $row['data'];
}
please note the line:
$array[] = $row['data'];