Rifts Posted October 14, 2010 Share Posted October 14, 2010 Hey everyone I'm pulling data from my db and then trying to store each value to its own var. the problem is the amount of values is always changing. here is what I have that isnt working $result = mysql_query("SELECT thismonth FROM list"); while($row = mysql_fetch_array($result)) { echo $row[0] . "<br>"; // this prints out all the values perfectly } no I just dont know how to store them so i can use them later. Quote Link to comment https://forums.phpfreaks.com/topic/215871-storing-pulled-data-into-individual-vars/ Share on other sites More sharing options...
Pawn Posted October 14, 2010 Share Posted October 14, 2010 $months = array(); while($row = mysql_fetch_assoc($result)) { $months[] = $row[0]; } print_r($months); Quote Link to comment https://forums.phpfreaks.com/topic/215871-storing-pulled-data-into-individual-vars/#findComment-1122168 Share on other sites More sharing options...
Rifts Posted October 14, 2010 Author Share Posted October 14, 2010 that out puts nothing Quote Link to comment https://forums.phpfreaks.com/topic/215871-storing-pulled-data-into-individual-vars/#findComment-1122176 Share on other sites More sharing options...
AbraCadaver Posted October 14, 2010 Share Posted October 14, 2010 Change mysql_fetch_assoc() to mysq_fetch_array(). Quote Link to comment https://forums.phpfreaks.com/topic/215871-storing-pulled-data-into-individual-vars/#findComment-1122210 Share on other sites More sharing options...
PFMaBiSmAd Posted October 14, 2010 Share Posted October 14, 2010 or just use $row['thismonth'] Quote Link to comment https://forums.phpfreaks.com/topic/215871-storing-pulled-data-into-individual-vars/#findComment-1122213 Share on other sites More sharing options...
Pawn Posted October 14, 2010 Share Posted October 14, 2010 Sorry, my bad. $months = array(); while($row = mysql_fetch_row($result)) { $months[] = $row[0]; } print_r($months); Or what PFMaBiSmAd said. Quote Link to comment https://forums.phpfreaks.com/topic/215871-storing-pulled-data-into-individual-vars/#findComment-1122214 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.