coder9 Posted July 26, 2008 Share Posted July 26, 2008 ok i have this $query = "SELECT * FROM jtablegrid WHERE game_no IN('$n1', '$n2', '$n3', '$n4', '$n5')"; $result=mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error()); now this is my attempt to extract it. while($row = mysql_fetch_array($result)) { echo $row[id][game_no]; echo "<br>"; } which is i tested and the result not correct. could you please show me how to do this the right way. Thank you in advance. Link to comment https://forums.phpfreaks.com/topic/116711-solved-im-trying-to-extract-these-5-numbers-from-a-single-query-is-this-correct/ Share on other sites More sharing options...
ignace Posted July 26, 2008 Share Posted July 26, 2008 while($row = mysql_fetch_array($result)) { echo $row['id']; // or replace 'id' with another jtablegrid.fieldname echo "<br>"; } Link to comment https://forums.phpfreaks.com/topic/116711-solved-im-trying-to-extract-these-5-numbers-from-a-single-query-is-this-correct/#findComment-600095 Share on other sites More sharing options...
coder9 Posted July 26, 2008 Author Share Posted July 26, 2008 while($row = mysql_fetch_array($result)) { echo $row['id']; // or replace 'id' with another jtablegrid.fieldname echo "<br>"; } thanks but i want to get both the id and game_no Link to comment https://forums.phpfreaks.com/topic/116711-solved-im-trying-to-extract-these-5-numbers-from-a-single-query-is-this-correct/#findComment-600096 Share on other sites More sharing options...
coder9 Posted July 26, 2008 Author Share Posted July 26, 2008 ok i got. while($row = mysql_fetch_array($result)) { echo "id: " .$row[id]; echo " "; echo "game no: " .$row[game_no]; echo "<br>"; } thanks to me. Link to comment https://forums.phpfreaks.com/topic/116711-solved-im-trying-to-extract-these-5-numbers-from-a-single-query-is-this-correct/#findComment-600102 Share on other sites More sharing options...
MFHJoe Posted July 26, 2008 Share Posted July 26, 2008 while($row = mysql_fetch_array($result)) { echo "id: " .$row[id]; echo " "; echo "game no: " .$row[game_no]; echo "<br>"; } Yep, that'll work, but it's much better practise to put quotes around the array indexes. Check out http://php.net/types.array under Array do's and dont's to understand why. Link to comment https://forums.phpfreaks.com/topic/116711-solved-im-trying-to-extract-these-5-numbers-from-a-single-query-is-this-correct/#findComment-600107 Share on other sites More sharing options...
JasonLewis Posted July 26, 2008 Share Posted July 26, 2008 ok i got. while($row = mysql_fetch_array($result)) { echo "id: " .$row[id]; echo " "; echo "game no: " .$row[game_no]; echo "<br>"; } thanks to me. Ignace helped you out a bit actually, pointed you in the right direction. Also, please change it from this: $row[game_no]; To this: $row['game_no']; Notice the apostrophes, they are actually quite important. Link to comment https://forums.phpfreaks.com/topic/116711-solved-im-trying-to-extract-these-5-numbers-from-a-single-query-is-this-correct/#findComment-600109 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.