Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/04/2008, 21:50
pivs
 
Fecha de Ingreso: abril-2008
Mensajes: 11
Antigüedad: 16 años, 1 mes
Puntos: 0
Imagenes asociadas a id

Hola a todos.
No se mucho de PHP y MYSQL, pero hago el intento. Mi consulta, ya que de codigo no se mucho es la siguiente.
Tengo una base con un Id numerico ej 123456 al cual le quiero asociar varias imagenes max 10. el tema es que e visto varios script, pero nada que me pueda ayudar.
En definitiva lo que necesito es que cuando se selecciona un item (123456) me muestre las imagenes asociadas a ese Id, con un simple slideshow. No se si podria ser como 123456_1.jpg, 123456_2.jpg, etc...
Muchas Gracias.

Tengo un slideshow simple, pero no se adaptarlo a mi necesidad. Lo dejo por siaca.
Código PHP:
<?php
header
("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// siempre modificado
header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0"false);
// HTTP/1.0
header("Pragma: no-cache");
require_once(
'conexion.php');
$qry=mysql_query("select * from galeria where identificador='{$_GET['identificador']}' order by id asc");
$miarrayphp=array();
$miarrayphp_txta=array();
while(
$row=mysql_fetch_assoc($qry)){
if(
$row['foto']!=""){
$miarrayphp[]='fotos/'.$row['foto'];
$miarrayphp_txta[]= ereg_replace('[[:space:]]+',' ',str_replace('"',"'",$row['contenido'])); 
}
$miarr=implode('","',$miarrayphp);
$miarrayphp_txt=implode('","',$miarrayphp_txta);
}
mysql_data_seek($qry,0); 
$imag=mysql_fetch_assoc($qry);
?>
<html>
<head>
<title>Imagenes</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
var directorio="";
var indice=0;
var miarray=new Array("<?php echo $miarr?>");
var miarray_txt=new Array("<?php echo $miarrayphp_txt?>");
function precarga(){
for(i=0;i<miarray.length;i++){
eval("imagen"+i+"=new Image();");
eval("imagen"+i+".src=" + "\"" +directorio+miarray<i>+"\";");
}
}
function cambia(como){
if(como=='menos'){
indice--;}else{indice++;}
if (indice < 0) indice = miarray.length - 1;
if (indice > miarray.length-1) indice = 0;
document.getElementById("cama").src=directorio+miarray[indice];
document.getElementById('leyenda').firstChild.nodeValue = (indice+1) + " de " + miarray.length;
document.getElementById('epi').innerHTML=miarray_txt[indice];
}
</script>
</head>
<body bgcolor="c8f05e" leftmargin="0" topmargin="0">
<table width="401" cellpadding="0" cellspacing="0">
  <tr>
    <td width="399" align="left" valign="top"> 
      <table width="399" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="10" rowspan="4" align="left" valign="top">&nbsp;</td>
          <td width="387" align="left" valign="top"> 
            <table width="134" align="center" cellpadding="0" cellspacing="0">
              <tr> 
                <td width="17" align="right" valign="middle"><a href="javascript:cambia('menos')">&lt;&lt;</a></td>
                <td width="55" align="center" valign="middle" class="galeria"><strong><div id="leyenda">1 
                              de <?php echo mysql_num_rows($qry); ?></div></strong></td>
                <td width="17" align="left" valign="middle"><a href="javascript:cambia('mas')">&gt;&gt;</a></td>
              </tr>
          </table>          </td>
        </tr>
        
        <tr> 
          <td align="left" valign="top"><table width="385" height="208" cellpadding="0" cellspacing="0">
              <tr> 
                <td width="383" height="187" align="center" valign="middle"><script>precarga();</script><img src="<?php
          
if($imag['foto']!='' && file_exists("fotos/".$imag['foto'])){echo "fotos/".$imag['foto'];} ?>" id="cama" name="cama"></td>
              </tr>
              <tr> 
                <td height="19" align="left" valign="top">&nbsp;</td>
              </tr>
            </table></td>
        </tr>
        <tr> 
          <td align="left" valign="top"><table width="387" height="37" cellpadding="0" cellspacing="0">
              <tr> 
                <td class="galeria"><div id="epi" class="galeria"><?php echo $miarrayphp_txta[0]; ?></div> </td>
              </tr>
            </table></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>
<?php
header
("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// siempre modificado
header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0"false);
// HTTP/1.0
header("Pragma: no-cache");
require_once(
'conexion.php');
$qry=mysql_query("select * from galeria where identificador='{$_GET['identificador']}' order by id asc");
$miarrayphp=array();
$miarrayphp_txta=array();
while(
$row=mysql_fetch_assoc($qry)){
if(
$row['foto']!=""){
$miarrayphp[]='fotos/'.$row['foto'];
$miarrayphp_txta[]= ereg_replace('[[:space:]]+',' ',str_replace('"',"'",$row['contenido'])); 
}
$miarr=implode('","',$miarrayphp);
$miarrayphp_txt=implode('","',$miarrayphp_txta);
}
mysql_data_seek($qry,0); 
$imag=mysql_fetch_assoc($qry);
?>
<html>
<head>
<title>Imagenes</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
var directorio="";
var indice=0;
var miarray=new Array("<?php echo $miarr?>");
var miarray_txt=new Array("<?php echo $miarrayphp_txt?>");
function precarga(){
for(i=0;i<miarray.length;i++){
eval("imagen"+i+"=new Image();");
eval("imagen"+i+".src=" + "\"" +directorio+miarray<i>+"\";");
}
}
function cambia(como){
if(como=='menos'){
indice--;}else{indice++;}
if (indice < 0) indice = miarray.length - 1;
if (indice > miarray.length-1) indice = 0;
document.getElementById("cama").src=directorio+miarray[indice];
document.getElementById('leyenda').firstChild.nodeValue = (indice+1) + " de " + miarray.length;
document.getElementById('epi').innerHTML=miarray_txt[indice];
}
</script>
</head>
<body bgcolor="c8f05e" leftmargin="0" topmargin="0">
<table width="500" cellpadding="0" cellspacing="0">
  <tr>
    <td align="left" valign="top"> 
      <table width="500" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="97" rowspan="4" align="left" valign="top">&nbsp;</td>
          <td width="385" align="left" valign="top"> 
            <table width="134" align="center" cellpadding="0" cellspacing="0">
              <tr> 
                <td width="17" align="right" valign="middle"><a href="javascript:cambia('menos')">&lt;&lt;</a></td>
                <td width="55" align="center" valign="middle" class="galeria"><strong><div id="leyenda">1 
                              de <?php echo mysql_num_rows($qry); ?></div></strong></td>
                <td width="17" align="left" valign="middle"><a href="javascript:cambia('mas')">&gt;&gt;</a></td>
              </tr>
          </table>          </td>
        </tr>
        
        <tr> 
          <td align="left" valign="top"><table width="386" height="275" cellpadding="0" cellspacing="0">
              <tr> 
                <td align="center" valign="middle"><script>precarga();</script><img src="<?php
          
if($imag['foto']!='' && file_exists("fotos/".$imag['foto'])){echo "fotos/".$imag['foto'];} ?>" id="cama" name="cama"></td>
              </tr>
              <tr> 
                <td align="left" valign="top">&nbsp;</td>
              </tr>
            </table></td>
        </tr>
        <tr> 
          <td align="left" valign="top"><table width="387" height="37" cellpadding="0" cellspacing="0">
              <tr> 
                <td class="galeria"><div id="epi" class="galeria"><?php echo $miarrayphp_txta[0]; ?></div> </td>
              </tr>
            </table></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>

Última edición por GatorV; 17/04/2008 a las 21:58 Razón: tags PHP