...

View Full Version : calling php from javascript



ronbanks
03-09-2005, 05:48 PM
Hello, I'm calling a php function from javascript to fill a javascript array. This sample code doesn't cause errors in php or javascript but just doesn't work. The goal here will be to return a row at a time in comma delimited format much like the mysql_fetch_array function in php. I will also post in the php forum but being new to both I am posting here also. I appreciate any help.

This is an example of the php function:

function PopulateRecsArray() {
global $recs; //a global array declared elsewhere
static $count;
if ($count == sizeof($recs)) {
$count = -1;
return false;
} else {
$count =+ 1;
}
for ($i = 0; $i < sizeof($recs); $i++) {
for ($j = 0; $j < sizeof($recs); $j++) {
$returnstr .= "\"{$recs[$count][$j]}\"";
}
return $returnstr;
}
}

This is an example of the calling javascript function:

function FillRecsArray() {
var row, rowcount = 0, colcount = 0;
while (row = PopulateRecsArray()) {
Recs[rowcount] = new Array();
Recs[rowcount][colcount] = row; //this is for testing just to get return value
count =+ 1;
}
}

hemebond
03-09-2005, 08:23 PM
You can not call a PHP function from Javascript like that.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum