RE: [PHP] How to adpated a javascrip with php...
| From: | Martin Towell | Date: | Tue, 11 Nov 2003 22:15:25 +0000 |
| Subject: | RE: [PHP] How to adpated a javascrip with php... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-169205@lists.php.net to get a copy of this message | ||
> I have a Javascript that I like to use with PHP/MYSQL, But I
> don't know
> how to mix the two...
>
> <SCRIPT LANGUAGE = "JavaScript">
> bName = navigator.appName;
> bVer = parseInt(navigator.appVersion);
>
> if ((bName == "Netscape" && bVer >= 3) ||
>
> (bName == "Microsoft Internet Explorer" && bVer >=
> 4)) br = "n3";
>
> else br = "n2";
>
> if (br == "n3") {
>
> boardNum = 0;
> boardSpeed = 4000;
>
> billboards = new Array();
> billboards[0] = new Image();
> billboards[0].src = "$x";
> billboards[1] = new Image();
> billboards[1].src = "$x";
> billboards[2] = new Image();
> billboards[2].src = "$x";
> billboards[3] = new Image();
> billboards[3].src = "$x";
> billboards[4] = new Image();
> billboards[4].src = "$x";
> billboards[5] = new Image();
> billboards[5].src = "$x";
> billboards[6] = new Image();
> billboards[6].src = "$x";
> billboards[7] = new Image();
> billboards[7].src = "$x";
> }
>
> [I like to make $x to be called from the database...]
>
>
> function rotateBoard() {
>
> document.billboard.src = billboards[boardNum].src;
>
> if (boardNum < billboards.length - 1) {
>
> boardNum++;
>
> } else {
>
> boardNum = 0;
>
> }
>
> }
>
> function jumpBillboard() {
>
> window.location.href = url[boardNum];
> }
> </SCRIPT>
Try something like this
billboards = new Array();
<?
$cursor = <<sql query here>>
$i = 0;
while ($something from database)
{
?>
billboards[<?=$i?>] = new Image();
billboards[<?=$i?>].src = "<?=$something?>";
<?
$i++;
}
?>
Martin