Rifts Posted March 15, 2010 Share Posted March 15, 2010 Hello! I'm pretty new to php/mysql so I hope my question makes sense I have this code: $sql = mysql_query("select * from members ORDER BY 'score' "); echo "<table border='1'>"; echo "<tr> <th>Name</th> <th>Score</th> </tr>"; while($row = mysql_fetch_array( $sql )) { echo "<tr><td>"; $asd = $row['name']; echo $row['FacebookID']; echo "</td><td>"; echo $row['score']; echo "</td></tr>"; } echo "</table>"; and it works just fine it prints out the 3 people in the data base with their score my question is this; is there anyway to set each of the three peoples name to different vars after they are printed? thanks Link to comment https://forums.phpfreaks.com/topic/195249-setting-each-fetch_array-to-vars/ Share on other sites More sharing options...
trq Posted March 15, 2010 Share Posted March 15, 2010 You could store them in an array to use latter. $members = array(); while($row = mysql_fetch_array( $sql )) { $members[] = $row; } Link to comment https://forums.phpfreaks.com/topic/195249-setting-each-fetch_array-to-vars/#findComment-1026122 Share on other sites More sharing options...
Rifts Posted March 15, 2010 Author Share Posted March 15, 2010 humm this might be exactly what I need... how would i use them later. for example if I wanted to echo the #3 person Link to comment https://forums.phpfreaks.com/topic/195249-setting-each-fetch_array-to-vars/#findComment-1026156 Share on other sites More sharing options...
trq Posted March 15, 2010 Share Posted March 15, 2010 echo $member[2]['name']; Link to comment https://forums.phpfreaks.com/topic/195249-setting-each-fetch_array-to-vars/#findComment-1026157 Share on other sites More sharing options...
Rifts Posted March 15, 2010 Author Share Posted March 15, 2010 i love you worked perfectly Link to comment https://forums.phpfreaks.com/topic/195249-setting-each-fetch_array-to-vars/#findComment-1026159 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.