I am trying to query a database of questions to bring back the list of questions..
my code so far is
Code: Select all
<?php
$questionSet = getQuesSet($surveyId);
function getQuesSet($surveyId)
{
$questions = func_get_args();
$mysqli = db_connect();
$query = "SELECT question FROM questions where surveyId = $surveyId";
$target = 0;
if ($result = $mysqli->query($query)) {
$count = 0;
/* fetch associative array */
while ($row = $result->fetch_assoc()) {
$questions[$count] = $row["question"];
$count++;
}
/* free result set */
$result->close();
}
/* close connection */
$mysqli->close();
return $questions;
}
?>
but i get this error, Undefined offset: 2 ??
Does anyone have a better way of doing this?