problem with arrays

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

problem with arrays

Post by itsmani1 »

value of

$ans = 1;

Code: Select all

$b[$ans] = $GameId;  
    
//what i think is it shoud  replace $b[1] 's old value with value of $GameId.

for($i=0; $i<4; $i++)
{
	$SkyRes1 = mysql_query("SELECT GameAnswer FROM `games` WHERE GameId = '$b[$i]'") or die(mysql_error());
	$Num1 = mysql_num_rows($SkyRes1);
	if($Num1 > 0)
	{
		if($SkyRow1 = mysql_fetch_object($SkyRes1))
		{
			$GameAnswer1 = $SkyRow1 -> GameAnswer;
		}
	}
}
but when i printed my query it gave me result some thing like this
Result

SELECT GameAnswer FROM `games` WHERE GameId = '7'
SELECT GameAnswer FROM `games` WHERE GameId = '6'
SELECT GameAnswer FROM `games` WHERE GameId = '3'
SELECT GameAnswer FROM `games` WHERE GameId = '2'

Thanx.
Mannan.
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

okies problem is solved.

actually problem was this that some times when "$GameId" comes with value >3 it was creating problem as array starts indexing from 0 and in this way it puts 4 value on 3rd location. this was the main probelem tht created issues for me.

...........
Mannan. :!:
Post Reply