Jump to content

get data using mysql_fetch_array returning only one row


cinek

Recommended Posts

I'm trying to return everything from a table using mysql_fetch_array, but it only returns the last row. here's the code

while($row = mysql_fetch_array($result))	{		$data['rows'] = array(					"id" => $row['id'],					"Company" => $row['Company'],					"Name" => $row['Name'],					"Status" => $row['Status']);	}

how can I fix this?

Link to comment
Share on other sites

You're overwriting data['rows'] every time. Maybe you wanted to do this instead:

$data['rows'] = array();while($row = mysql_fetch_array($result))	{		$data['rows'][] = array(					"id" => $row['id'],					"Company" => $row['Company'],					"Name" => $row['Name'],					"Status" => $row['Status']);	}

P.S. mysql_fetch_array() does only return one row at a time - that's why there's the while loop.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...