mostafatalebi Posted December 16, 2012 Share Posted December 16, 2012 Hello I have a mySQL table with six rows, How can I query all of them and put them one by one in a variable or an array? thanks Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted December 16, 2012 Share Posted December 16, 2012 Where are you stuck, exactly? Quote Link to comment Share on other sites More sharing options...
mostafatalebi Posted December 16, 2012 Author Share Posted December 16, 2012 I mean I have a table, with six rows. Each row has a text in it. I want to query the table and get all six rows, putting each row's text into a variable, so at the end I have six variables or an array with six element. Something like looping through. But I don't know how Quote Link to comment Share on other sites More sharing options...
trq Posted December 16, 2012 Share Posted December 16, 2012 Assuming $results holds the result of your call to mysql_query(). $allResults = []; while ($row = mysql_fetch_assoc($results)) { $allResults[] = $row; } $allResults will now be an array containing all your rows. Quote Link to comment Share on other sites More sharing options...
mostafatalebi Posted December 16, 2012 Author Share Posted December 16, 2012 Ha! Thanks alot Quote Link to comment 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.