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); Quote 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. } Quote Link to comment https://forums.phpfreaks.com/topic/211116-mysql_fetch_array/#findComment-1101065 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.