Page 1 of 1

Getting query result into an array

Posted: Tue Oct 21, 2003 7:51 am
by toddnyc3
[Admin Edit: Topic split from viewtopic.php?t=13761]

Hi,

I came across this while trying very hard to figure out exactly what it is I am doing wrong here and finally dropped the whole pride thing and am asking for help. Below is the last of the 1,349,732 attempts at this. What is seemingly very simple leaves me with an empty array at the end. If anyone has a suggestion I would absolutely love to hear it as I am at my wits end.

Code: Select all

$data = array();
$query = "select * from standings where week = $week order  by gbehind asc, mper desc, mwon desc, gwon desc, tname ";
$result = mysql_query( $query );
while($row = mysql_fetch_row($result));
{
$dataї] = array($row);
}
I have tried a number of different ways of populating the array, such as array_push() and others.

Thanks in advance,

T

Posted: Tue Oct 21, 2003 8:41 am
by volka

Code: Select all

$data = array();
$query = "select * from standings where week = $week order  by gbehind asc, mper desc, mwon desc, gwon desc, tname ";
$result = mysql_query( $query );
while($row = mysql_fetch_row($result));
	$data[] = $row; // append the array $row as new element to the array $data
	
print_r($data);