Jump to content

Recommended Posts

Hi everyone  :)

 

i'm new in all this stuff of php and i want to create an automatic slideshow i already do one but this one is manual you have to click on a button to change the image and i want to be automatic- manual i mean that the user can change the image if he click the button or if nothing happens in 5 sec the image changes.

 

the code of the manual slideshow is here

 


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>prueba mysql</title>

<script language="javascript" type="text/javascript">
<!--
function siguiente(){
if(posicion==imagenes.length-1){posicion=0;}
else {posicion=posicion+1;}
document.images[0].src=imagenes[posicion];
document.getElementById('numero').innerHTML=posicion+1;
document.getElementById('comentario').innerHTML=comentarios[posicion];
document.getElementById('ligafoto').href=ligas[posicion];
}
function previo(){
if(posicion==0){posicion=imagenes.length-1;}
else {posicion=posicion-1;}
document.images[0].src=imagenes[posicion];
document.getElementById('numero').innerHTML=posicion+1;
document.getElementById('comentario').innerHTML=comentarios[posicion];
document.getElementById('ligafoto').href=ligas[posicion];
}

//-->
</script>

<?php 
$i=0;$primerfoto=array();
$texto="<script language=\"javascript\" type=\"text/javascript\" >var actual =0; var posicion =0; var imagenes = new Array();var comentarios = new Array(); var ligas = new Array();";
$link = mysql_connect("localhost:3306","root","");

mysql_select_db("duop",$link);
$sql="select * from imagenessecuencia";
$rs = mysql_query($sql,$link);
$totalRows_fotos = mysql_num_rows($rs);
while($row=mysql_fetch_assoc($rs)){
if($i==0)$primerfoto=$row;

$texto.="imagenes[$i]='".$row['ruta']."';";
$texto.="comentarios[$i]='".$row['texto']."';";
$texto.="ligas[$i]='".$row['direccion']."';";


$i++;
}
mysql_free_result($rs);
mysql_close($link);   

$texto.="</script>";
echo $texto;

?>
</style>
</head>

<body>
<p><a id="ligafoto" href="<?php if($primerfoto['direccion'])echo $primerfoto['direccion'];?>" >
<img src="<?php if($primerfoto['ruta'])echo $primerfoto['ruta']; else echo "/du//imagenessecuencia/001.jpg";?>" alt="" width="400" height="300" border="0"></a></p>

<div><span>
  <label id="comentario">
  <?php if($primerfoto['texto'])echo $primerfoto['texto'];?>
  </label>
</span></div>

<div><?php if($totalRows_fotos){?>
  <a href="#"><img src="imagenes/left.gif" width="20" height="22" border="0" onClick="previo();"></a>Foto 
  <label id="numero">1</label> de 
      <?php echo $totalRows_fotos; ?><a href="#"><img src="imagenes/right.gif" width="20" height="22" border="0" onClick="siguiente();"></a><br>
      <?php } else echo "No hay fotos asociadas a esta obra";?>
</div>
</body>
</html>

 

pls tell me how to add a funtion to change the images automatic every 5 sec

 

tnx ;)

Link to comment
https://forums.phpfreaks.com/topic/63658-creating-an-automatic-slideshow/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.