Getting query result into an array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
toddnyc3
Forum Newbie
Posts: 1
Joined: Tue Oct 21, 2003 7:51 am
Location: New York

Getting query result into an array

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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);
Post Reply