Hello, I am retrieving code from a database and my resulting array is as below.
Array (
[0] => Array ( [0] => False [1] => True )
[1] => Array ( [0] => True [1] => False )
[2] => Array ( [0] => False [1] => True )
[3] => Array ( [0] => True [1] => False )
[4] => Array ( [0] => False [1] => True )
[5] => Array ( [0] => True [1] => False )
[6] => Array ( [0] => True [1] => False )
[7] => Array ( [0] => False [1] => True )
[8] => Array ( [0] => False [1] => True )
[9] => Array ( [0] => True [1] => False )
[10] => Array ( [0] => False [1] => True )
[11] => Array ( [0] => True [1] => False )
[12] => Array ( [0] => True [1] => False )
[13] => Array ( [0] => False [1] => True )
[14] => Array ( [0] => True [1] => False )
Can someone please explain a script on how I can access the first answer of each array element. e.g.
[0],[0]
[1],[0]
[2],[0]
[3],[0]
[4],[0]
This is really bugging me, I need to compare each of the above elements with a form variable of true or false??
My code is below, please ask any questions if something is not clear?
Many thanks
James
$connection = mysql_connect("localhost","root","root") or die("couldn't connect");
$select = mysql_select_db("login") or die ("cannot select database!");
$query = mysql_query("SELECT answer FROM questions");
$numrows = mysql_num_rows($query); //count the number of rows {45}
if ($numrows!=0) //if number of rows does not equal 0
{
$count = 0; //counter set to 0
while($row = mysql_fetch_assoc($query)) //while a row exists
{
$correctanswer[$count] = explode('|',$row['answer']); // //get answer row from database and place in $correctanswer to get correct answer
$count++;//increment the counter
//print_r($correctanswer[$count]);
}
print_r($correctanswer);
echo $correctanswer['1,0'];
}