Search the Community
Showing results for tags 'phparray'.
-
I've only been learning php for two weeks so please excuse my ignorance, I would like to store an array of data from a mysql table in a variable to be called as and when its needed in my script. i have written this function and used a vardump just to check wether the function was working: function getquestions($id) { $sql =mysql_query("select text FROM questions WHERE quiz_ID =$id "); while($row = mysql_fetch_array($sql)) { var_dump($row) ; } } ///Actual code $quizid = get_id("quizName", "ID"); $questionid = get_id("questions","quiz_ID"); if ($quizid == $questionid) { $question = getquestions("1"); } BUT my array lists all of my row values twice like this: array(2) { [0]=> string(68) "The ‘Sea Swallow’ is an alternative name for which bird?" ["text"]=> string(68) "The ‘Sea Swallow’ is an alternative name for which bird?" } array(2) { [0]=> string(58) "In which sport would you see a ‘Western Roll’?" ["text"]=> string(58) "In which sport would you see a ‘Western Roll’?" } array(2) { [0]=> string(53) "Who is better known as ‘Herbert Khaury’?" ["text"]=> string(53) "Who is better known as ‘Herbert Khaury’?" } array(2) { [0]=> string(42) "'Diet' is the parliament of which country?" ["text"]=> string(42) "'Diet' is the parliament of which country?" } array(2) { [0]=> string(43) "What is the real first name of Coco Chanel?" ["text"]=> string(43) "What is the real first name of Coco Chanel?" } array(2) { [0]=> string(43) "'The Aztecs' were natives of which country?" ["text"]=> string(43) "'The Aztecs' were natives of which country?" } array(2) { [0]=> string(54) "What was invented by‘O.A. North’ in 1869?" ["text"]=> string(54) "What was invented by‘O.A. North’ in 1869?" } array(2) { [0]=> string(40) "King Zog was the ruler of which country?" ["text"]=> string(40) "King Zog was the ruler of which country?" } I'd appreciate any explanation on how i stop this.