Hello all, I have a small problem with javascript and php what am trying to do is re-code the following script so that the items array uses a php script and a loop to gets information from a database but i dont know how to go about it can anyone help ?
code would look abit like this but ofc it would need a loop feature to get and build all adverts from the database
items[<?php echo raw['sort']; ?>]="<a href='<?php echo raw['url']; ?>' target='_blank'><img alt='<?php echo raw['details']; ?>' src='<?php echo raw['image']; ?>' height='60' width='468' border='0'/></a>";
full script code below
<script language="JavaScript1.2">
var howOften = 12; //number often in seconds to rotate
var current = 0; //start the counter at 0
var ns6 = document.getElementById&&!document.all;
// place your images, text, etc in the array elements here
// this is the section i like to change to php to get items ID and image url so on ...
var items = new Array();
items[0]="<a href='#' target='_blank'><img alt='advertisements' src='default_banner.gif' height='60' width='468' border='0'/></a>";
items[1]="<a href='#' target='_blank'><img alt='advertisements' src='4u_banner_three.gif' height='60' width='468' border='0'/></a>";
function rotater() {
document.getElementById("placeholder").innerHTML = items[current];
current = (current==items.length-1) ? 0 : current + 1;
setTimeout("rotater()",howOften*1000);
}
function rotater() {
if(document.layers) {
document.placeholderlayer.document.write(items[current]);
document.placeholderlayer.document.close();
}
if(ns6)document.getElementById("placeholderdiv").innerHTML=items[current]
if(document.all)
placeholderdiv.innerHTML=items[current];
current = (current==items.length-1) ? 0 : current + 1; //increment or reset
setTimeout("rotater()",howOften*1000);
}
window.onload=rotater;
//-->
</script>
hope sumone can help thanks
Yours
Simon