Lassie Posted February 26, 2008 Share Posted February 26, 2008 I am trying to adapt an ajax script to allow content to be dynamically selected and diplayed. The contant is held in a db as refences to the page locations ie field p1= chapters.html and the ref field holds the folder name. I need to create an array of the page references and pass this to a javascript var. I cant figure how to cycle through the pages array and make a valid location reference. Can anyone help please. The relevant code is //get product_id $product_id=13; //connect to db $connection=db_connect(); echo "<script type='text/javascript'>\n"; //Dynamically output JavaScript opening tag echo "var mysettings={}\n"; //Dynamically output javascript variable $pageids=mysql_query("select p1,p2,p3 from ajax WHERE product_id='$product_id'"); $idarray=array(); while ($theid=mysql_fetch_array($pageids)){ array_push($idarray, "'http://localhost/folder/?id=" . $theid[id] . "'");//create folder and page locations } echo "mysettings.page=[" . implode(",", $idarray) . "]\n"; echo "mysettings.selectedpage=0\n"; echo "</script>\n"; //Dynamically output JavaScript closing tag Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.