Hi I'm trying to pass a Php array from a database selection to Jscript array.
I can't seem to get it working
Could anyone help me with this problem
Here are my codes.
<?php
$i = 0;
@include('adodb/adodb.inc.php');
ADOLoadCode('access'); // load Access code
$con = &ADONewConnection(); // create a connection
$con->Connect('CD2'); // connect to MS-Access using DSN name
$recordSet = &$con->Execute("SELECT LessonCode, LessonTitle FROM Lesson");
while(!$recordSet->EOF) {
$temp = new array();
$temp[$i] = $recordSet->fields[0].' '.@$recordSet->fields[1];
$recordSet->MoveNext();
$i++;
}
$i = $i + 1; //to get the amount of elements within the array
echo "<script language=\"Javascript\">";
?>
var cwArray = array(<?php $i; ?> );
<?php
for($k = 0; $k < $i; $k++) {
?>
cwArray[<?php echo $k; ?> = <?php echo $temp[$k]; ?>;
<?php
}
echo "</script>";
?>
Thanks