imgSrc = new Array('foto1','foto2','foto3','foto4');
da mesma forma ele busca o link da noticia, o texto a ser exibido. Com o código que eu postei abaixo, só consegui fazer com que ele exibisse 1 destaque, seja aleatório ou ordenado por "id", tenho um modelo de teste com o problema em: Destaque - Foto na Festa
Vejam o code abaixo e me ajudem, PLZ
VLW!!!
<? $sql = mysql_query("SELECT * FROM destaque WHERE categoria='fotodia' AND id_franquia='$cidade' order by rand()");$total = mysql_num_rows($sql);if($total > 0){?><? while($dados=mysql_fetch_array($sql)){?><html><head><script src="functions.js"></script><link type="text/css" rel="stylesheet" href="styles.css" /></head><script>// arrays que compõem a chamadaimgSrc = new Array('thumbs.php?w=205&h=135&imagem=images/destaques/<? echo $dados[foto];?>','thumbs.php?w=205&h=135&imagem=images/destaques/<? echo $dados[foto];?>','thumbs.php?w=205&h=135&imagem=images/destaques/<? echo $dados[foto];?>','thumbs.php?w=205&h=135&imagem=images/destaques/<? echo $dados[foto];?>');lnkSrc = new Array('?pg=noticia&id=<?=$dados[id_galeria];?>','?pg=noticia&id=<?=$dados[id_galeria];?>','?pg=noticia&id=<?=$dados[id_galeria];?>','?pg=noticia&id=<?=$dados[id_galeria];?>');chpSrc = new Array('Geral','','','');txtSrc = new Array('<?=$dados["texto"];?>','<?=$dados["texto"];?>','<?=$dados["texto"];?>','<?=$dados["texto"];?>');icoSrc = new Array('','','','','');altSrc = new Array('<?=$dados["texto"];?>','<?=$dados["texto"];?>','<?=$dados["texto"];?>','<?=$dados["texto"];?>');<? }?><? } else {?><? }?>// funcoes ////function delItem(arr,item) {for (;item<arr.length;item++) arr[item] = arr[item + 1];arr.length=arr.length-1;}function goURL(){(lnkSrc[atual].indexOf('_blank')!=-1) ? window.open(lnkSrc[atual].substring(0,lnkSrc[atual].indexOf(' '))) : location.href=lnkSrc[atual];}function changeImg(id){clearTimeout(timeoutId);atual+=parseInt(id);if(atual>imgSrc.length-1) atual = 0;if(atual<0) atual = imgSrc.length-1;if(document.all) { document.images.img1.style.filter="blendTrans(duration=1)"; document.images.img1.filters.blendTrans.Apply(); document.images.img1.filters.blendTrans.Play(); }document.img1.src = imgDsp[atual].src;document.img1.alt = document.img1.title = altSrc[atual];document.getElementById('txt1').innerHTML = txtSrc[atual];document.getElementById('chp1').innerHTML = chpSrc[atual];document.icon.src = icoSrc[atual];document.getElementById('space').innerHTML = (document.icon.src=="http://img.uol.com.br/x.gif") ? '' : ' ' ;timeoutId = setTimeout("changeImg(1)",6000)}function startSlide() { timeoutId = setTimeout("changeImg(1)",6000); }// main ////for(i=txtSrc.length-1;i>=0;i--) // remove os arrays com tamanho menor de 3 chars // { if(icoSrc[i].length<3) icoSrc[i] = "http://img.uol.com.br/x.gif"; // preenche as chamadas sem icone com x.gif if(imgSrc[i].length<3||lnkSrc[i].length<3||txtSrc[i].length<3||altSrc[i].length<2||chpSrc[i].length<2) { delItem(imgSrc,i); delItem(lnkSrc,i); delItem(txtSrc,i); delItem(icoSrc,i); delItem(altSrc,i); delItem(chpSrc,i); } }if(txtSrc.length==1) document.write("<style>#anterior,#proxima{visibility:hidden}</style>"); // se só tem 1 imagem, some com proximo/anterioratual = Math.random().toString().substring(2,6) % imgSrc.length; // escolhe uma imagem inicial randomicamenteimgDsp = new Array();for(n=0;n<imgSrc.length;n++) // pre-load das imagens { imgDsp[n] = new Image(); imgDsp[n].src = imgSrc[n]; }timeoutId = 0;onload = startSlide;// escreve na tela [ALTERE AQUI] ///document.write('<table width="205" height="205" border="0" cellpadding="0" cellspacing="0">');document.write('<tr>'); document.write('<td colspan="4" bgcolor="#000000" style="border: solid 1px #000;"> <a href="java script:goURL()"" id="lnk1"><img src='+imgSrc[atual]+' width="205" height="135" name=img1 border=0 title="'+altSrc[atual]+'" alt="'+altSrc[atual]+'"></a></td>'); document.write('</tr>');document.write('<tr>'); document.write('<td height="40" colspan="4" bgcolor="#000000" style="border: solid 1px #000;">'); document.write('<span id=space> </span><a href=java script:goURL() id=lnk2 style=color:#ffffff>'); document.write('<span id=a13nw><span id=txt1>'+ txtSrc[atual] +'</span></span></a></div></td>');document.write('</tr>');document.write('<tr> ');document.write('<td height="13" valign=bottom style="background-color: #000;"><a href=java script:changeImg(-1) id=anterior><img src=estrutura/botao_anterior.gif border=0></a></td>');document.write('<td height="13" align=right valign=bottom style="background-color: #000;"><a href=java script:changeImg(1) id=proxima><img src=estrutura/botao_proximo.gif border=0></a></td>');document.write('</tr>');document.write('</table>');</script>
Edição feita por: DarkSign, 29/05/2008, 16:23.
Colocar o codebox pra melhor visualização











