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. Quote Link to comment 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>"; } Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. 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.