Jump to content

[SOLVED] I'm trying to extract these 5 numbers from a single query. is this correct?


Recommended Posts

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.

 

 

 

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.