Foros del Web » Programando para Internet » PHP »

Problema con foreach...

Estas en el tema de Problema con foreach... en el foro de PHP en Foros del Web. Saludos... estoy haciendo un catalogo de productos donde al entrar a la ficha de descripcion tngo un include q me muestra la galeria d dicho ...
  #1 (permalink)  
Antiguo 04/08/2008, 15:41
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Problema con foreach...

Saludos...
estoy haciendo un catalogo de productos donde al entrar a la ficha de descripcion tngo un include q me muestra la galeria d dicho producto.. pero me da este error

Warning: Invalid argument supplied for foreach() in C:\wamp\www\albarracin\ficha.php on line 119

alguien puede ayudarme??? aqui les dejo
Código PHP:
<?php require_once('conect.php');
@
$id=$_REQUEST['id'];
$sql="SELECT * FROM galeria WHERE prod_id = $id";
$sql_exec=mysql_query($sql);
// Variables de Configuración -----------------------------------
// Define el numero de Filas
$n_filas=3;

//***************************************************************
@$type=$_REQUEST['type'];
@
$brand=$_REQUEST['brand'];
$cat=$Id_truck;
//$cat=6;

$fotos = array();

$tottal=113;
// ------------------------------------------------------------------------------------------------------------------
$vert=$tottal/$n_filas;
$vert=round($vert);
?>
<link href="estilos.css" rel="stylesheet" type="text/css" />
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script language="javascript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);

}
function cambiar(ruta){
document.imgamp.src = ruta;
}
window.onload = cargar;
//-->
var loteImagenes=new Array();
<?php
// Abrir un directorio conocido, y proceder a leer sus contenidos
$dir "files/".$fol;
if (
is_dir($dir)) {
    if (
$gd opendir($dir)) {
    
$cont=0;
        while ((
$archivo readdir($gd)) !== false) {
        if (
$archivo != "."){
        if (
$archivo != ".."){
        if (
$archivo != "Thumbs.db"){
            
$laf$dir."/".$archivo;
            echo 
"loteImagenes[".$cont."]='".$laf."';";
                
$img[$cont] = $laf;
                
$cont=$cont+1;
    }    }    }    }
        
closedir($gd);
    }
}

/*$pics = array();
$cont=0;
while($rowx=mysql_fetch_assoc($sql_execx)){
echo "loteImagenes[".$cont."]='".$rowx['img]."';";
$img[$cont] = $rowx['img'];
$cont=$cont+1;
}*/
?>
var i=0;
function anterior(){
if(i<1){
var NumImagen = i;
}else{
var NumImagen = i-=1;
}
document.imgamp.src = loteImagenes[NumImagen];
}
function siguiente(){
if(i>loteImagenes.length-2){
var NumImagen=i;
}else{
var NumImagen= i+=1;
}
document.imgamp.src = loteImagenes[NumImagen];
 

}
function nav(pic){
i=pic;
document.imgamp.src = loteImagenes[pic];
}
function cargar(){
document.imgamp.src = "<?=$img[4]?>";
}

</script>
<table width="260" border="0" align="center" cellpadding="2" cellspacing="1">
  <tr>
    <td width="260" height="75" bgcolor="#F3F3F3">
      <div id="ampliar" style="margin-left:5px; margin-right:5px; margin-top:5px; margin-bottom:5px;"><img alt="Foto Principal" name="imgamp" width="220" height="0" border="0" id="imgamp" /></div>    </td>
  </tr>
  
  <tr>
    <td><table width="175" height="16" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="74" align="right"><a href="#" onclick="anterior();"><img src="bw.jpg" alt="&lt; - Back" width="28" height="15" border="0" /></a></td>
        <td width="27" align="center"><img src="imagenes/separ_btns.jpg" alt="a" width="8" height="13" /></td>
        <td width="74"><a href="#" onclick="siguiente();"><img src="fw.jpg" alt="Forward -&gt;" width="28" height="15" border="0" /></a></td>
      </tr>
    </table></td>
  </tr>
</table>
<br />
<table width="220" height="91" border="0" align="center" cellpadding="0" cellspacing="5">
  <!--DWLayoutTable-->
  <tr>
    <td width="220" height="81"><table width="220" height="85" border="0" align="center" cellpadding="0" cellspacing="5">
        
        <?php
        
        $a
=0;// Colocando el contador horizontal en 0
        
$i=1;// Colocando el contador vertical en 0
        
$w=0;//Colocando un contador para el mensaje de "No hay articulos en esta acategoria"
        
$z=0;//contador para el JS
            
foreach($img as $e) {//linea 119
            
$w=w+1;
                if (
$a==0){
                echo 
'<tr>';
                }
                
$a=$a+1;
                
$fotos[$i.'-'.$a] = $e;
                
                echo 
"<td height='64' width='64'><a href='#' onmouseover='nav(".$z.")' onclick=\"MM_openBrWindow('imagen.php?pic=".$e."&Id_truck=".$Id_truck."','imagen','width=600,height=400')\"><img src=".$e." width='64' height='64'border='0'/></a>";
            
$z=$z+1;
                
$r=$a;// contador remanente para listar imagenes sin exceso
                
                    
if ($a >= $n_filas) {
                    
$a=0;// reiniciando el contador horizontal
                    
$i=$i+1;// aumentando el contador vertical
                    
echo '</tr>';
                    } 
            if (empty(
$img)) {
        echo
"<table width='0' border='0' align='center' cellpadding='0' cellspacing='0'>
          <tr>
            <td width='220'><div align='center'>No hay fotos en esta galeria</div></td>
          </tr>
        </table>
        "
;
        break 
1;}
            
            }
            
         echo 
'</td>';
        
?>
        <?php /*if (empty($w)) {
        echo"<table width='0' border='0' align='center' cellpadding='0' cellspacing='0'>
          <tr>
            <td width='492'><div align='center'>No hay articulos en esta categoria </div></td>
          </tr>
        </table>
        ";
        exit;}
        */
?>
    </table></td></tr>
</table>
</p>
Gracias
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...

Última edición por T4ke0veR; 04/08/2008 a las 16:01
  #2 (permalink)  
Antiguo 04/08/2008, 15:52
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Problema con foreach...

De donde obtienes la variable $img?

Saludos.
  #3 (permalink)  
Antiguo 04/08/2008, 16:02
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: Problema con foreach...

de la funcion q esta como js supongo...
Código PHP:
<?php
// Abrir un directorio conocido, y proceder a leer sus contenidos
$dir "files/".$fol;
if (
is_dir($dir)) {
    if (
$gd opendir($dir)) {
    
$cont=0;
        while ((
$archivo readdir($gd)) !== false) {
        if (
$archivo != "."){
        if (
$archivo != ".."){
        if (
$archivo != "Thumbs.db"){
            
$laf$dir."/".$archivo;
            echo 
"loteImagenes[".$cont."]='".$laf."';";
                
$img[$cont] = $laf;
                
$cont=$cont+1;
    }    }    }    }
        
closedir($gd);
    }
}

/*$pics = array();
$cont=0;
while($rowx=mysql_fetch_assoc($sql_execx)){
echo "loteImagenes[".$cont."]='".$rowx['img]."';";
$img[$cont] = $rowx['img'];
$cont=$cont+1;
}*/
?>
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #4 (permalink)  
Antiguo 04/08/2008, 16:03
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: Problema con foreach...

mis campos en la tabla galeria son
id <- primary
prod_id
img
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #5 (permalink)  
Antiguo 05/08/2008, 07:21
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: Problema con foreach...

nadie sabe?
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #6 (permalink)  
Antiguo 05/08/2008, 07:50
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Problema con foreach...

Es probable que tu variable $dir este mal formada y is_dir no encuentre el directorio, prueba esto:
Código PHP:
$dir "files/".$fol;
if (
is_dir($dir)) {
    if (
$gd opendir($dir)) {
    
$cont=0;
        while ((
$archivo readdir($gd)) !== false) {
        if (
$archivo != "."){
        if (
$archivo != ".."){
        if (
$archivo != "Thumbs.db"){
            
$laf$dir."/".$archivo;
            echo 
"loteImagenes[".$cont."]='".$laf."';";
                
$img[$cont] = $laf;
                
$cont=$cont+1;
    }    }    }    }
        
closedir($gd);
    }
} else {
    die( 
"Error fatal, $dir no es un directorio" );

Saludos.
  #7 (permalink)  
Antiguo 05/08/2008, 07:56
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: Problema con foreach...

gracias gatorv... ese era el problema!!!!
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #8 (permalink)  
Antiguo 05/08/2008, 08:53
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: Problema con foreach...

pasa algo....
cuando incluyo ese php q se llama ficha dentro de otro y hago el llamado del producto no me muestra nada.. pagina se me corta... pero si no lo incluyo me muestra los datos a la perfeccion!!!
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #9 (permalink)  
Antiguo 05/08/2008, 09:07
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Problema con foreach...

A que te refieres con "se te corta".

Saludos.
  #10 (permalink)  
Antiguo 05/08/2008, 09:07
Avatar de foreverOdd  
Fecha de Ingreso: noviembre-2007
Ubicación: Caracas
Mensajes: 489
Antigüedad: 16 años, 5 meses
Puntos: 14
Respuesta: Problema con foreach...

verificaste que $_REQUEST tenga el contenido por el que preguntas al principio del archivo ficha???

quiza el problema este ahi
__________________
My path is lit by my own fire, I only go where I desire
  #11 (permalink)  
Antiguo 05/08/2008, 09:20
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: Problema con foreach...

GatorV a esto me refiero
Con include

sin include


el include es el mismo codigo q estamos aqui discutiendo!!!! cuando lo inserto en otra página me la corta al tratar de mostrar los datos :S
y fireverOdd
si t das cuenta si me traigo lo q me agarra el request...
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #12 (permalink)  
Antiguo 05/08/2008, 09:23
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Problema con foreach...

¿Haz visto el código fuente para ver si te esta marcando algún error, o ver la posicion exacta (en HTML) donde se corta?

Saludos.
  #13 (permalink)  
Antiguo 05/08/2008, 09:28
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: Problema con foreach...

si pues... he revisado un poco.. y d verdad ni idea.. fijate en esto...
esta en la pagina donde esta incluida la ficha...q no es mas q una galeria de imagenes
Código PHP:
<?php require_once('Connections/alba.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

$colname_Recordset1 "-1";
if (isset(
$_GET['id'])) {
  
$colname_Recordset1 $_GET['id'];
}
mysql_select_db($database_alba$alba);
$query_Recordset1 sprintf("SELECT * FROM productos WHERE id = %s"GetSQLValueString($colname_Recordset1"int"));
$Recordset1 mysql_query($query_Recordset1$alba) or die(mysql_error("Error fatal"));
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
    font-size: 11px;
    font-family: Arial, Helvetica, sans-serif;
}
-->
</style>
<link href="css/estilo.css" rel="stylesheet" type="text/css" />
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="2">
  <tr>
    <td width="29%" rowspan="2"><img src="logo/<?php //aqui es donde se corta echo $row_Recordset1['logo']; ?>" border="0" /></td>
    <td width="29%">&nbsp;</td>
    <td width="42%" rowspan="3"><table width="260" border="0" align="center" cellpadding="0" cellspacing="2">
      <tr>
        <td><?php include('ficha.php'); ?></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="95%" border="0" align="center" cellpadding="0" cellspacing="2">
      <tr>
        <td width="11%"><img src="http://www.forosdelweb.com/images/flecha.gif" width="17" height="15" /></td>
        <td width="89%"><span class="style1">Volver a listado</span></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">
      <tr>
        <td bgcolor="#E8E7C1"><p>&nbsp;</p>
          <table width="80%" border="0" align="center" cellpadding="0" cellspacing="2">
          <tr>
            <td class="descPRODUCTOS"><div align="justify"><?php echo $row_Recordset1['descripcion']; ?></div></td>
            </tr>
        </table>
          <p>&nbsp;</p></td>
      </tr>
    </table></td>
  </tr>
</table>
<?php
mysql_free_result
($Recordset1);
?>
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #14 (permalink)  
Antiguo 05/08/2008, 11:09
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: Problema con foreach...

,, he hecho algunos cambioa y aun nada.....

Código PHP:
<?php require_once('conect.php');
@
$id=$_REQUEST['id'];
$sql="SELECT * FROM galeria WHERE prod_id = $id";
$sql_exec=mysql_query($sql) or die ("Error en consulta: $sql_execex, error: "mysql_error());
// Variables de Configuración -----------------------------------
// Define el numero de Filas
$n_filas=3;

//***************************************************************
$cat=$id;
//$cat=6;

$fotos = array();

$tottal=113;
// ------------------------------------------------------------------------------------------------------------------
$vert=$tottal/$n_filas;
$vert=round($vert);
?>
<link href="estilos.css" rel="stylesheet" type="text/css" />
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script language="javascript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);

}
function cambiar(ruta){
document.imgamp.src = ruta;
}
window.onload = cargar;
//-->
var loteImagenes=new Array();
<?php
// Abrir un directorio conocido, y proceder a leer sus contenidos
$dir "galeria/".$fol;
if (
is_dir($dir)) {
    if (
$gd opendir($dir)) {
    
$cont=0;
        while ((
$archivo readdir($gd)) !== false) {
        if (
$archivo != "."){
        if (
$archivo != ".."){
        if (
$archivo != "Thumbs.db"){
            
$laf$dir."/".$archivo;
            echo 
"loteImagenes[".$cont."]='".$laf."';";
                
$img[$cont] = $laf;
                
$cont=$cont+1;
    }    }    }    }
        
closedir($gd);
    }
} else {
    die( 
"Error fatal, $dir no es un directorio" );
}  

/*$pics = array();
$cont=0;
while($rowx=mysql_fetch_assoc($sql_execx)){
echo "loteImagenes[".$cont."]='".$rowx['img]."';";
$img[$cont] = $rowx['img'];
$cont=$cont+1;
}*/
?>
var i=0;
function anterior(){
if(i<1){
var NumImagen = i;
}else{
var NumImagen = i-=1;
}
document.imgamp.src = loteImagenes[NumImagen];
}
function siguiente(){
if(i>loteImagenes.length-2){
var NumImagen=i;
}else{
var NumImagen= i+=1;
}
document.imgamp.src = loteImagenes[NumImagen];
 

}
function nav(pic){
i=pic;
document.imgamp.src = loteImagenes[pic];
}
function cargar(){
document.imgamp.src = "<?=$img[4]?>";
}

</script>
<table width="260" border="0" align="center" cellpadding="2" cellspacing="1">
  <tr>
    <td width="260" height="75" bgcolor="#F3F3F3">
      <div id="ampliar" style="margin-left:5px; margin-right:5px; margin-top:5px; margin-bottom:5px;"><img alt="Foto Principal" name="imgamp" width="220" height="0" border="0" id="imgamp" /></div>    </td>
  </tr>
  
  <tr>
    <td><table width="175" height="16" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="74" align="right"><a href="#" onclick="anterior();"><img src="bw.jpg" alt="&lt; - Back" width="28" height="15" border="0" /></a></td>
        <td width="27" align="center"><img src="imagenes/separ_btns.jpg" alt="a" width="8" height="13" /></td>
        <td width="74"><a href="#" onclick="siguiente();"><img src="fw.jpg" alt="Forward -&gt;" width="28" height="15" border="0" /></a></td>
      </tr>
    </table></td>
  </tr>
</table>
<br />
<table width="220" height="91" border="0" align="center" cellpadding="0" cellspacing="5">
  <!--DWLayoutTable-->
  <tr>
    <td width="220" height="81"><table width="220" height="85" border="0" align="center" cellpadding="0" cellspacing="5">
        
        <?php
        
        $a
=0;// Colocando el contador horizontal en 0
        
$i=1;// Colocando el contador vertical en 0
        
$w=0;//Colocando un contador para el mensaje de "No hay articulos en esta acategoria"
        
$z=0;//contador para el JS
            
foreach($img as $e) {
            
$w=w+1;
                if (
$a==0){
                echo 
'<tr>';
                }
                
$a=$a+1;
                
$fotos[$i.'-'.$a] = $e;
                
                echo 
"<td height='64' width='64'><a href='#' onmouseover='nav(".$z.")' onclick=\"MM_openBrWindow('imagen.php?id=".$e."','imagen','width=600,height=400')\"><img src=".$e." width='64' height='64'border='0'/></a>";
            
$z=$z+1;
                
$r=$a;// contador remanente para listar imagenes sin exceso
                
                    
if ($a >= $n_filas) {
                    
$a=0;// reiniciando el contador horizontal
                    
$i=$i+1;// aumentando el contador vertical
                    
echo '</tr>';
                    } 
            if (empty(
$img)) {
        echo
"<table width='0' border='0' align='center' cellpadding='0' cellspacing='0'>
          <tr>
            <td width='220'><div align='center'>No hay fotos en esta galeria</div></td>
          </tr>
        </table>
        "
;
        break 
1;}
            
            }
            
         echo 
'</td>';
        
?>
        <?php /*if (empty($w)) {
        echo"<table width='0' border='0' align='center' cellpadding='0' cellspacing='0'>
          <tr>
            <td width='492'><div align='center'>No hay articulos en esta categoria </div></td>
          </tr>
        </table>
        ";
        exit;}
        */
?>
    </table></td></tr>
</table>
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #15 (permalink)  
Antiguo 05/08/2008, 12:03
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Problema con foreach...

Se corta en <img src="logo?

En ese caso no creo que sea problema de la ficha en si... si no de alguna otra cosa en tu código.

Por otro lado checa tu require_once, el problema puede venir de ahi, si no encuentra "conect.php", al ser require, marcara error si no lo puede incluir.

Saludos.
  #16 (permalink)  
Antiguo 06/08/2008, 09:07
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: Problema con foreach...

bueno gator el error q me daba fue muy gafo... cuando le digo por el explorador "ver codigo fuente" decia justo donde se corta "Error fatal galeria/ es no es un directorio" ... lo cree y funciono... ahora... el codigo me dice q llama a una imagen principal.. pero jamas me la muestra.... tngo esa duda.. cual seria la imagen principal a mostrar???

Código PHP:
<?php
// Abrir un directorio conocido, y proceder a leer sus contenidos
$dir "galeria/".$fol;
if (
is_dir($dir)) {
    if (
$gd opendir($dir)) {
    
$cont=0;
        while ((
$archivo readdir($gd)) !== false) {
        if (
$archivo != "."){
        if (
$archivo != ".."){
        if (
$archivo != "Thumbs.db"){
            
$laf$dir."/".$archivo;
            echo 
"loteImagenes[".$cont."]='".$laf."';";
                
$img[$cont] = $laf;
                
$cont=$cont+1;
    }    }    }    }
        
closedir($gd);
    }
} else {
    die( 
"Error fatal, $dir no es un directorio" );
}  

/*$pics = array();
$cont=0;
while($rowx=mysql_fetch_assoc($sql_execx)){
echo "loteImagenes[".$cont."]='".$rowx['img]."';";
$img[$cont] = $rowx['img'];
$cont=$cont+1;
}*/
?>
var i=0;
function anterior(){
if(i<1){
var NumImagen = i;
}else{
var NumImagen = i-=1;
}
document.imgamp.src = loteImagenes[NumImagen];
}
function siguiente(){
if(i>loteImagenes.length-2){
var NumImagen=i;
}else{
var NumImagen= i+=1;
}
document.imgamp.src = loteImagenes[NumImagen];
 

}
function nav(pic){
i=pic;
document.imgamp.src = loteImagenes[pic];
}
function cargar(){
document.imgamp.src = "<?=$img[1]?>";
}

</script>
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #17 (permalink)  
Antiguo 06/08/2008, 09:15
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Problema con foreach...

Pues al parecer va a leer la segunda imagen que encuentre en el directorio, ya que es lo que tu le indicas en esta linea:
Código:
function cargar(){
document.imgamp.src = "<?=$img[1]?>";
}
Saludos.
  #18 (permalink)  
Antiguo 06/08/2008, 09:52
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: Problema con foreach...

aaaaaaaaaaaaaaaaah entiendo!!!!... gracias :)
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:12.