Ver Mensaje Individual
  #15 (permalink)  
Antiguo 21/02/2012, 07:04
edie8
 
Fecha de Ingreso: noviembre-2011
Mensajes: 516
Antigüedad: 13 años, 4 meses
Puntos: 10
Respuesta: Duda con valores while

consigo q se vean hasta un maximo de tres fotos como puedo hacer para que se vean mass fotos este es el codigo que pongo:
Código PHP:
<?php
include('../config.php');
$resultados=mysql_query("select * from imagenes where id_logueado='$id_usuario'",$conexion) or 
  die(
"Problemas en el select:".mysql_error());
$i 1;
$arr=array();
  while(
$fot=mysql_fetch_assoc($resultados)) 

$foto_nombre=$fot['nombre'];
$foto_id=$fot['id'];
$arr[]=$foto_nombre;

/*$arr = array($i => '<img src="'.$foto_nombre.'" alt="Img '.$i.'" rel="'.$i.'" />',);*/
$arr1= array($i=> $foto_nombre);


/*?><img src="<?php echo $arr[$i]; ?>" /><?php */
}

/*echo '<img src="'.$arr1[$i].'" alt="Img '.$i.'" rel="'.$i.'">';*/
$i++;
/*echo $arr[$i];*/
$registros=mysql_query("select count(*) as cantidad  from imagenes where id_logueado='$id_usuario'",$conexion) or
  die(
"Problemas en el select:".mysql_error());
  
$reg=mysql_fetch_array($registros);
  
$cantidad=$reg['cantidad'];
  if(
$_POST["img"] > $cantidad)
  { 
    
?><img src="<?php echo $arr[1]; ?>" /><?php 
    
}
else
    {
    
?><img src="<?php echo $arr[$_POST["img"]+1];?>" /><?php 
    
}
?>
y este es el codigo que hace q se pasen las fotos al click
Código PHP:
<script type="text/javascript">
$(document).ready(function()
    {
    $("#click-cambio > img").livequery('click', function ()
         {
        $.post("lib/procesa.php", { img: $(this).attr("rel") }, function(data)
            {
            $("#click-cambio").html(data);
            });
        });
    });
</script>
</head>
<body>

<div id="click-cambio">
    <?php
    $id
=$_GET['id'];
    include(
'config.php');
$resultados=mysql_query("select * from imagenes where id='$id'",$conexion) or 
  die(
"Problemas en el select:".mysql_error());
$i 1;
$arr=array();
  while(
$fot=mysql_fetch_assoc($resultados)) 

$foto_nombre=$fot['nombre'];
$arr=array (=> '<img src="' .$foto_nombre.'" alt="Img ' .$i.'" rel="'.$i.'" />');
}
    echo 
$arr[1];
    unset(
$i);
    
?>
</div>
Nose que mas cambios hacer para que me funcione como funcionaba antes sin base de datos, como lo tengo q acer? gracias.