Programación Web y Scripting > PHP
Galeria de Imagenes Simple con PHP + Mysql
(1/1)
LUCKATONI:
Tengo una base de datos con una tabla imagenes:
Id Nombre Ruta
En el campo "Ruta" esta la Ruta de la imagen.
Lo que quiero hacer es mostrar una galeria de imagenes simple leyendo el campo "Ruta" de la BD.
Por Ejemplo:
|----------| |----------| |--------- | |--------- |
| | | | | | | |
|--------- | |--------- | |--------- | |--------- |
|----------| |--------- | |--------- | |--------- |
| | | | | | | |
|--------- | |--------- | |--------- | |--------- |
Yo consegui hacerlas, pero todas seguidas, no soy capaz de hacer que me heche 4 imagenes por cada linea(tr)
Muchas Gracias
RadicalEd:
pasate con un ciclo while o for, cuando llegue a un mod 4 = 0 entonces coloca un nuevo <tr>
LUCKATONI:
<form method="post" action="gallery.php" name="ver">
<table>
<tr><td width="120">Tema:</td><td> <input type="text" name="titulo" size="20" id="titulo1b"/></td><td><input type="submit" value="Abrir Archivo" name="ver"></td></tr>
</table>
</form>
if(isset($_REQUEST['ver'])){
$tema=$_REQUEST['titulo'];
$select= mysql_query("select ruta from imagenes where tema='$tema' ");
echo "<table>";
echo "<tr>";
while (@$file=mysql_fetch_array($select))
{
// @$file2=mysql_fetch_array($select2);
for ($i=0; $i<1; $i++){
if ($i<6) {
echo "<td><a href='$file[$i]'><img src='$file[$i]' width='200' height='100'></img></a></td>";
}else;
}
}
echo "</tr>";
echo "</table>";
}
else;
Eso es lo que he hecho, pero como puedes ver, una vez pido dato en el formulario(form), pues me salen las imagenes correspondientes, pero todas seguidas, sin ningun <tr>
Gracias
RadicalEd:
if ($i%6==0) {
Navegación
Ir a la versión completa