Jump to content

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


coder9

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.