I[0] = new Array(); I[0,0]= what is your name I[0,1]= new array();
I[0,1,0] = new array(); I[0,1,0,0] = joe I[0,1,0,1] = "feedback"
I[0,1,0,2] = I[0,1,1] = new array(); I[0,1,1,0] = dontknow I[0,1,1,1]
= 'feedback' I[0,1,1,2] = 0 I[0,1,2] = new array(); I[0,1,2,0] =
"dontcare" I[0,1,2,1] = \'feedback\' I[0,1,2,2] = 0 I[0,1,3] = new
array(); I[0,1,3,0] = ahhh I[0,1,3,1] = 'feedback' I[0,1,3,2] = 0
I[0,2] = 0
here is the code... I[] is the js array which I wish to pass values
to.
<?PHP
require_once("config.php");
require_once("includes/sql_layer.php");
$dbi = sql_connect($dbhost, $dbuname, $dbpass, $dbname);
$sql = "SELECT
nuke_quizzz_questions.quizid,
nuke_quizzz_questions.questiontext,
nuke_quizzz_questions.rightanswer,
nuke_quizzz_questions.wronganswera,
nuke_quizzz_questions.wronganswerb,
nuke_quizzz_questions.wronganswerc,
nuke_quizzz_questions.wronganswerd,
nuke_quizzz_questions.submittedby ";
$sql .= " FROM nuke_quizzz_questions";
$result = mysql_query($sql);
#one = 1;
$zero = 0;
$type = "";
$number2 = "0";
$counter = 0;
while ($myrow = mysql_fetch_row($result)) {
print ("I[$counter] = new Array();\n");
print ("I[$counter,0]= $myrow[1]\n");
print ("I[$counter,1]= new array();\n");
print ("I[$counter,1,0] = new array();\n");
print ("I[$counter,1,0,0] = $myrow[2]\n");
print ("I[$counter,1,0,1] = \"feedback\"\n");
print ("I[$counter,1,0,2] = $one\n");
print ("I[$counter,1,1] = new array();\n");
print ("I[$counter,1,1,0] = $myrow[3]\n");
print ("I[$counter,1,1,1] = 'feedback'\n");
print ("I[$counter,1,1,2] = $zero \n");
print ("I[$counter,1,2] = new array();\n");
print ("I[$counter,1,2,0] = \"$myrow[4]\" \n");
print ("I[$counter,1,2,1] = \'feedback\' \n");
print ("I[$counter,1,2,2] = $zero\n");
print ("I[$counter,1,3] = new array();\n");
print ("I[$counter,1,3,0] = $myrow[5]\n");
print ("I[$counter,1,3,1] = 'feedback'\n");
print ("I[$counter,1,3,2] = $zero\n");
print ("I[$counter,2] = $zero \n");
#$counter++;
}
?>
You should change lines like:
print ("I[$counter,0]= $myrow[1]\n");
in
print ("I[$counter,0]= '$myrow[1]'\n");
so with single quotes surrounding the variables. Of course, you could do
also
print ("I[$counter,0]= \"$myrow[1]\"\n");
Further more, use the PHP function stripslashes() to strip escape characters
from your variables before using them.
HTH
Janwillem