Ciao a tutti!
Dopo aver abbondantemente frugato sul forum, sono finalmente riuscita a implementare con successo un bel Javascript per far ruotare i banner (da query MySQL). Tuttavia si comporta in modo strano. Se lo richiamo due volte con la stessa query, i banner "gemelli" funzionano entrambi; ma se cambio la query del secondo banner per pescare da un'altra tabella MySQL, il secondo banner non da' segni di vita.

Sono abbastanza "scafata" in PHP ma conosco pochissimo Javascript...
Qualcuno di voi saprebbe cortesemente indicarmi come fare per modificare lo script e vedere due sequenze di banner pescate da tabelle MySQL diverse?

Javascript (non ho modificato nulla)
codice:
/****
* Banner Ad Rotater v3.02
* Anarchos > anarchos3@hotmail.com
* http://anarchos.xs.mw/bannerad.phtml
**/

function Banner(refreshTime, width, height, altText, start, random){
	this.objName = "bannerAd" + (Banner.count++);
	eval(this.objName + "=this");
	if (!refreshTime) this.refreshTime = 5000; else this.refreshTime = refreshTime*1000;
	if (!width) this.width = 180; else this.width = width;
	if (!height) this.height = 68; else this.height = height;
	if (random == null) this.random = 1; else this.random = random;
	this.altText = altText;
	this.ads = [];
	if (start) this.currentAd = start-1; else start = null;
	this.mySize = 0;

	this.Ad = function(src, href, target, mouseover) {
		var tempImage = new Image();
		tempImage.src = src;
		this.ads[this.mySize] = new Object();
		var ad = this.ads[this.mySize];
		ad.src = src;
		if (typeof(target) == "undefined" || target == null) ad.target = "_self"; else ad.target = target;
		ad.href = href;
		ad.mouseover = mouseover;
		this.mySize++;
	}

	this.link = function(){
		var	ad = this.ads[this.currentAd];
		if (ad.target == "_self"){
			location.href = ad.href;
		}
		else if (ad.target == "_blank" || ad.target == "_new"){
			open(ad.href,this.objName + "Win");
		}
		else top.frames[ad.target].location.href = ad.href;
	}

	this.showStatus = function(){
		var ad = this.ads[this.currentAd];
		if (ad.mouseover) status = ad.mouseover;
		else status = ad.href;
	}

	this.randomAd = function(){
		var n;
		do { n = Math.floor(Math.random() * (this.mySize)); } 
		while(n == this.currentAd);
		this.currentAd = n;
	}

	this.output = function(){
		var tempCode = "";
		if (this.mySize > 1){
			if (this.currentAd == null) this.randomAd();
			if (this.currentAd >= this.mySize) this.currentAd = this.mySize - 1;
			tempCode = '<a href="javascript:'+this.objName+'.link();"';
			tempCode += ' onMouseOver="' + this.objName + '.showStatus(); return true"';
			tempCode += ' onMouseOut="status=\'\';return true">';
			tempCode += '[img]' + this.ads[this.currentAd].src + '[/img]</a>';
			document.write(tempCode);
			this.nextAd();
		} else document.write("Error: two banners must be defined for the script to work.");
	}

	this.newAd = function(){
		if (!this.random){	
			this.currentAd++;
			if (this.currentAd >= this.mySize)
			   this.currentAd = 0;
		}
		else {
			this.randomAd();
		}
		this.nextAd();
	}

	this.nextAd = function(){
		document.images[this.objName+ 'Img'].src = this.ads[this.currentAd].src;
		setTimeout(this.objName+'.newAd()',this.refreshTime)
	}
}
Banner.count = 0;
Lo script JS qui sopra viene richiamato nell'header della pagina web
codice:
<script src="functions/banner_rotator.js" type="text/javascript"></script>
Funzione PHP che carica il Javascript "a comando"
codice:
<?php
// SELEZIONO I DISTRIBUTORI DA DB E CARICO I LOGHI A ROTAZIONE TRAMITE JAVASCRIPT
// ATTENZIONE
// Richiede la seguente riga in <head>
/* <script src="banner_rotator.js" type="text/javascript"></script> */

function banner_rotator($banner, $link=NULL) {
	// Javascript dinamico per i banner
	echo '<script type="text/javascript">
	/* parameters for Banner() are:
	time between rotations (seconds), width of banners, height of banners, alt text, starting banner, and random (0 means it iterates through banners, 1 means it randomly picks the next banner).
	parameters for Ad() are:
	path to image, url, target (use "_blank" to open in a new window), and mouseover message. For most of these parameters, a null tells the script to use the default value. 
	*/
	myAd = new Banner( 4, 180, "Clicca", 1, 0 );';
	foreach ($banner as $value) {
		echo 'myAd.Ad( "'.$value.'", "'.$link.'", "_blank", "#" );';
	} 
	echo 'myAd.output();
	</script>'; 
}
?>
Pagina PHP che mostra due banner con rotazione
codice:
<?php require_once 'functions/banner_rotator2.php'; ?>

<table align="center" width="180" height="180" cellspacing="0" class="menuBorder">
<tr align="center"><td>
<?php
$sql = "SELECT * FROM web_distrib";
$result = mysql_query($sql) or die(mysql_error());
$banner = array();
$link = array();
while ($row = mysql_fetch_assoc($result)) {
	$banner[] .= 'images/distrib/'.$row['logo'].'.gif';
	$link[] .= $row['sito'];
}
banner_rotator($banner);
?>
</td></tr></table>


<table align="center" width="180" height="180" cellspacing="0" class="menuBorder">
<tr align="center"><td>
<?php
$sql2 = "SELECT * FROM web_gallery";
$result2 = mysql_query($sql2) or die(mysql_error());
$banner = array();
$link = array();
while ($row2 = mysql_fetch_assoc($result2)) {
	$banner[] .= 'images/gallery/'.$row2['sw'].'_'.$row2['zona'].'_'.$row2['filenum'].'.gif';
	$link[] .= '#';
}

banner_rotator($banner);
?>
</td></tr></table>
Grazie in anticipo!