ahs10 Posted February 9, 2008 Share Posted February 9, 2008 so i have for results that i want to run the same code over. i can't figure out how to get a variable variable name to work in my while loop though. something to the effect of... $result1 = mysql_query($query1); $result2 = mysql_query($query2); $result3 = mysql_query($query3); $result4 = mysql_query($query4); for ($i = 1; $i < 5; $i++) { while ($row = mysql_fetch_array($result[$i])) { //here's my code to be repeated on each result, referring to $row and column names like $row['id'] } } what's wrong? Link to comment https://forums.phpfreaks.com/topic/90246-variable-variable-name-multiple-result-sets/ Share on other sites More sharing options...
Barand Posted February 9, 2008 Share Posted February 9, 2008 try while ($row = mysql_fetch_array(${'result'.$i})) { Link to comment https://forums.phpfreaks.com/topic/90246-variable-variable-name-multiple-result-sets/#findComment-462736 Share on other sites More sharing options...
ahs10 Posted February 10, 2008 Author Share Posted February 10, 2008 rock on, thanks. it makes so much sense when you see the answer...... Link to comment https://forums.phpfreaks.com/topic/90246-variable-variable-name-multiple-result-sets/#findComment-463324 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.