Foros del Web » Programando para Internet » PHP »

Bucle con un array

Estas en el tema de Bucle con un array en el foro de PHP en Foros del Web. estimados estoy desarrollando una web de noticias y quisiera hacer que me cargue dinamicamente una cantidad X. Obtengo los datos de la db en un ...
  #1 (permalink)  
Antiguo 06/11/2014, 07:23
 
Fecha de Ingreso: febrero-2011
Ubicación: Azul
Mensajes: 12
Antigüedad: 13 años, 2 meses
Puntos: 0
Bucle con un array

estimados estoy desarrollando una web de noticias y quisiera hacer que me cargue dinamicamente una cantidad X.

Obtengo los datos de la db en un array y quisiera hacer un bucle for(creo que es el mejor??) me podrian ayudar??

Aca les dejo el codigo: el for arrancaria desde la 4ta noticia.

<div class="col-md-10" style="padding:0; margin:0;">
<!--Primer Noticia-->
<div class="col-md-8">
<div id="<?php echo obtenerEstilos(obtenerSeccionDoble($portadita[5],$secciones)); ?>">
<h6 style="float:left;"><?php echo obtenerSeccionDoble($portadita[5],$secciones);?></h6>
<div class="fb-share-button" data-href="nota.php?id=<?php echo $portadita[0];?>"></div>
<a style="float:right; margin-left:2px;" data-href="https://www.facebook.com/dialog/feed?app_id=404023909670002&link=http%3A%2F%2Fnota .php?id=<?php echo $portadita[0];?>" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('iconos_sociales','','im g/facebook_2.png',1)">
<img src="img/facebook_1.png" width="30" height="30" id="iconos_sociales">
</a>
<a target="_blank" style="float:right; margin-left:2px; margin-right:5px;" href="www.twitter.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('twitter','','img/twitter_2.png',1)">
<img src="img/twitter_1.png" width="30" height="30" id="twitter"></a>
<div style="clear:both"></div>
</div>
<span>
<?php echo $portadita[1];?>
</span>
<h1>
<a href="nota.php?id=<?php echo $noticias[0][0];?>" style="color:#000"><?php echo $portadita[2];?></a>
</h1><spam>
<?php echo $portadita[3];?>
</spam>
<?php
$imagenes = obtenerImagenes($portadita[6]);
echo "<a href='nota.php?id=".$portadita[0]."'><img src='panel/noticias/imagenes/".$imagenes[0]."' width='95%'></a>";
?></div><!--Fin Primer Noticia-->
<!--Segunda Noticia-->
<div class="col-md-4">
<div id="<?php echo obtenerEstilos(obtenerSeccionDoble($noticias[1][5],$secciones)); ?>">
<h6 style="float:left;"><?php echo obtenerSeccionDoble($noticias[1][5],$secciones);?></h6>
<a target="_blank" style="float:right; margin-left:2px;" href="www.facebook.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('face2','','img/facebook_2.png',1)">
<img src="img/facebook_1.png" width="30" height="30" id="face2">
</a>
<a target="_blank" style="float:right; margin-left:2px; margin-right:5px;" href="www.twitter.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('twitter2','','img/twitter_2.png',1)">
<img src="img/twitter_1.png" width="30" height="30" id="twitter2">
</a>
<div style="clear:both"></div>
</div><span>
<?php echo $noticias[1][1];?>
</span>
<h4>
<a href="nota.php?id=<?php echo $noticias[1][0];?>" style="color:#000"><?php echo $noticias[1][2];?></a>
</h4>
<?php
$imagenes = obtenerImagenes($noticias[1][6]);
echo "<a href='nota.php?id=".$noticias[1][0]."'><img src='panel/noticias/imagenes/".$imagenes[0]."' width='95%'></a>";
?><br/><br/>
<spam>
<?php echo $noticias[1][3];?> </spam>
<!--Fin Segunda Noticia-->
<!--Tercera Noticia-->
<div id="<?php echo obtenerEstilos(obtenerSeccionDoble($noticias[2][5],$secciones)); ?>">
<h6 style="float:left;"><?php echo obtenerSeccionDoble($noticias[2][5],$secciones);?></h6>
<a target="_blank" style="float:right; margin-left:2px;" href="www.facebook.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('face3','','img/facebook_2.png',1)">
<img src="img/facebook_1.png" width="30" height="30" id="face3">
</a>
<a target="_blank" style="float:right; margin-left:2px; margin-right:5px;" href="www.twitter.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('twitter3','','img/twitter_2.png',1)">
<img src="img/twitter_1.png" width="30" height="30" id="twitter3">
</a>
<div style="clear:both"></div>
</div>
<span>
<?php echo $noticias[2][1];?>
</span>
<h3 style="padding-top:0px; margin-top:0; margin-botton:0;">
<a href="nota.php?id=<?php echo $noticias[2][0];?>" style="color:#000; line-height: 1em;"><?php echo $noticias[2][2];?></a>
</h3>
<?php
$imagenes = obtenerImagenes($noticias[2][6]);
echo "<a href='nota.php?id=".$noticias[2][0]."'><img src='panel/noticias/imagenes/".$imagenes[0]."' width='85%' style='margin-left:5%;'></a>";?>
</div>
<!--Fin Tercer Noticia-->
<!-- Fin Noticias Primer Fila-->
<div style="clear:both; margin:1%"></div><br/><br/>
<div class="col-md-4"><!-- Inicio Noticias Primer Columna-->
<!--=Cuarta Noticia-->
<div id="<?php echo obtenerEstilos(obtenerSeccionDoble($noticias[3][5],$secciones)); ?>">
<h6 style="float:left;"><?php echo obtenerSeccionDoble($noticias[3][5],$secciones);?></h6>
<a target="_blank" style="float:right; margin-left:2px;" href="www.facebook.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('face4','','img/facebook_2.png',1)">
<img src="img/facebook_1.png" width="30" height="30" id="face4">
</a>
<a target="_blank" style="float:right; margin-left:2px; margin-right:5px;" href="www.twitter.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('twitter4','','img/twitter_2.png',1)">
<img src="img/twitter_1.png" width="30" height="30" id="twitter4">
</a>
<div style="clear:both"></div>
</div>
<spam>
<?php echo $noticias[3][1];?> </spam>
<h4>
<a href="nota.php?id=<?php echo $noticias[3][0];?>" style="color:#000"><?php echo $noticias[3][2];?></a>
</h4>
<?php
$imagenes = obtenerImagenes($noticias[3][6]);
echo "<a href='nota.php?id=".$noticias[2][0]."'><img src='panel/noticias/imagenes/".$imagenes[0]."' width='95%'></a>";
?>
<spam>
<?php echo $noticias[3][3];?>
</spam>
<!--Fin Cuarta Noticia-->
<br/><br/>
</div><!-- Fin Noticias Primer Columna-->
<div class="col-md-4"><!-- Inicio Noticias Segunda Columna-->
<!--Quinta Noticia-->
<div id="<?php echo obtenerEstilos(obtenerSeccionDoble($noticias[4][5],$secciones)); ?>">
<h6 style="float:left;"><?php echo obtenerSeccionDoble($noticias[4][5],$secciones);?></h6>
<a target="_blank" style="float:right; margin-left:2px;" href="www.facebook.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('face8','','img/facebook_2.png',1)">
<img src="img/facebook_1.png" width="30" height="30" id="face8">
</a>
<a target="_blank" style="float:right; margin-left:2px; margin-right:5px;" href="www.twitter.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('twitter8','','img/twitter_2.png',1)">
<img src="img/twitter_1.png" width="30" height="30" id="twitter8">
</a>
<div style="clear:both"></div>
</div>
<spam>
<?php echo $noticias[4][1];?>
</spam>
<h4>
<a href="nota.php?id=<?php echo $noticias[4][0];?>" style="color:#000"><?php echo $noticias[4][2];?></a>
</h4>
<?php
$imagenes = obtenerImagenes($noticias[4][6]);
echo "<a href='nota.php?id=".$noticias[4][0]."'><img src='panel/noticias/imagenes/".$imagenes[0]."' width='95%'></a>";
?>
<spam>
<?php echo $noticias[4][3];?>
</spam>
<!--Fin Quinta Noticia-->
<br/><br/>
</div> <!--Fin Segunda Columna Noticia-->
<div class="col-md-4"><!--Inicio Tercer Columna Noticia-->
<!--Sexta Noticia-->
<div id="<?php echo obtenerEstilos(obtenerSeccionDoble($noticias[5][5],$secciones)); ?>">
<h6 style="float:left;"><?php echo obtenerSeccionDoble($noticias[5][5],$secciones);?></h6>
<a target="_blank" style="float:right; margin-left:2px;" href="www.facebook.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('face12','','img/facebook_2.png',1)">
<img src="img/facebook_1.png" width="30" height="30" id="face12">
</a>
<a target="_blank" style="float:right; margin-left:2px; margin-right:5px;" href="www.twitter.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('twitter12','','img/twitter_2.png',1)">
<img src="img/twitter_1.png" width="30" height="30" id="twitter12">
</a>
<div style="clear:both"></div>
</div>
<spam>
<?php echo $noticias[5][1];?> </spam>
<h4>
<a href="nota.php?id=<?php echo $noticias[5][0];?>" style="color:#000"><?php echo $noticias[5][2];?></a>
</h4>
<?php
$imagenes = obtenerImagenes($noticias[5][6]);
echo "<a href='nota.php?id=".$noticias[5][0]."'><img src='panel/noticias/imagenes/".$imagenes[0]."' width='95%'></a>";
?>
<spam>
<?php echo $noticias[5][3];?>
</spam>
<!--Fin Sexta Noticia-->
<br/><br/>
</div>
<!--Fin Decima Quinta Noticia-->

Muchas Gracias!!!

Etiquetas: bucle
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 17:15.