c_pattle Posted August 18, 2010 Share Posted August 18, 2010 Hi. I just have a quick question. If I perform a mysql query like the one below that returns all of the rows in a table. How do I then add all of this data into an array. If I use the following code bellow the variable $array will only contain the first row of the table. $rs = mysql_query($query, $conn); $array = mysql_fetch_array ($rs); Link to comment https://forums.phpfreaks.com/topic/211116-mysql_fetch_array/ Share on other sites More sharing options...
jcbones Posted August 19, 2010 Share Posted August 19, 2010 Simple answer. $rs = mysql_query($query, $conn); while($row = mysql_fetch_array ($rs)) { //loop through the data, $array[] = $row; //and collect the rows. } Link to comment https://forums.phpfreaks.com/topic/211116-mysql_fetch_array/#findComment-1101065 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.