Foros del Web » Programando para Internet » PHP »

Mi Galería de fotografías

Estas en el tema de Mi Galería de fotografías en el foro de PHP en Foros del Web. Hola a todos finalmente pude realizar mi galeria ahora surgieron los siguientes problemas o mas bien me gustaría tener algunas características extra. 1° Este es ...
  #1 (permalink)  
Antiguo 01/12/2005, 10:10
 
Fecha de Ingreso: junio-2005
Mensajes: 13
Antigüedad: 18 años, 10 meses
Puntos: 0
Mi Galería de fotografías

Hola a todos finalmente pude realizar mi galeria ahora surgieron los siguientes problemas o mas bien me gustaría tener algunas características extra.

1° Este es mi instalador.
Código PHP:
<html>
<body>

<?PHP
define 
("CONSTANTE""Instalación del sistema de galerias");
printf (CONSTANTE);
?>

</body>
</html>
<?
$basedatos 
"ondanxd_fotos";

//conectamos con el servidor

$link = @mysql_connect("localhost""root""pass");

 

// comprobamos que hemos estabecido conexión en el servidor

if (! $link){

echo 
"<h2 align='center'>ERROR: Imposible establecer conección con el servidor</h2>";

exit;

}

// obtenemos una lista de las bases de datos del servidor

$db mysql_list_dbs();

 

// vemos cuantas BD hay

$num_bd mysql_num_rows($db);

 

//comprobamos si la BD que quermos crear exite ya

$existe "NO" ;

for (
$i=0$i<$num_bd$i++) {

if (
mysql_dbname($db$i) == $basedatos) {

$existe "SI" ;

break;

}

}

 

// si no existe la creamos

if ($existe == "NO") {

/* manera 1 */

if (! mysql_create_db($basedatos$link)) {

echo 
"<h2 align='center'>ERROR 1: Imposible crear base de datos</h2>";

exit;



/* class="codigo" style="margin-left: 50"> /* manera 2 

if (! mysql_query("CREATE DATABASE $basedatos", $link)){

echo "<h2 align='center'>ERROR2: Imposible crear base de datos</h2>";

exit;

} */

}

 

// creamos la tabla

$sql "CREATE TABLE galerias (";

$sql .= "id INT NOT NULL AUTO_INCREMENT, ";

$sql .= "nombre CHAR(50), ";

$sql .= "portada CHAR(50), ";

$sql .= "direccion CHAR(50), ";

$sql .= "fecha CHAR(50), ";

$sql .= "fotografo CHAR(50), ";

$sql .= "KEY (id) ) ";

 

if (@
mysql_db_query($basedatos$sql$link)) {

echo 
"<h2 align='center'>La tabla se ha creado con éxito</h2>";

} else {

echo 
"<h2 align='center'>No se ha podido crear la tabla</h2>";

}

 

?>

 

</body>
</html>
Archivo de conexion aunque en algunos no lo incluí

Código PHP:
<html>
<head>
<title>Conexion a la base de datos</title>
</head>
<body>
<?php
function Conectarse()
{
   if (!(
$link=mysql_connect("localhost","root","pass")))
   {
      echo 
"Error conectando a la base de datos.";
      exit();
   }
   if (!
mysql_select_db("db_fotos",$link))
   {
      echo 
"Error seleccionando la base de datos.";
      exit();
   }
   return 
$link;
}

$link=Conectarse();

mysql_close($link); //cierra la conexion
?>
</body>
</html> 

</body>
</html>
2° Este es mi formulario para el registro de nuevas galerías, se insertan a la base de datos pero... me gustaría que me impirera lo que hizo.

Código PHP:
<html>
<head>
   <title>Nueva galeria</title>
</head>
<body>
<H1>Insertar nuevas fotografías</H1>
<FORM NAME="insertar" METHOD="post" ACTION="procesar.php">
<TABLE>
<TR>
   <TD>Nombre:</TD>
   <TD><INPUT TYPE="text" NAME="nombre" SIZE="20" MAXLENGTH="50"></TD>
</TR>
<TR>
   <TD>Fecha:</TD>
   <TD><INPUT TYPE="text" NAME="fecha" SIZE="20" MAXLENGTH="30"></TD>
</TR>
<TR>
   <TD>Portada:</TD>
   <TD><INPUT TYPE="text" NAME="portada" SIZE="30" MAXLENGTH="50"></TD>
</TR>
<TR>
   <TD>Galeria:</TD>
   <TD><INPUT TYPE="text" NAME="galeria" SIZE="30" MAXLENGTH="50"></TD>
</TR>
<TR>
   <TD>Fotografo:</TD>
   <TD><INPUT TYPE="text" NAME="fotografo" SIZE="20" MAXLENGTH="20"></TD>
</TR>
</TABLE>
<INPUT TYPE="submit" NAME="enviar" method="post" VALUE="Grabar">
</FORM>
<hr>
<?php
   
include("conexion.php");
   
$link=Conectarse();
   
$result=mysql_query("select * from galeria",$link);
?>
   <TABLE BORDER=1 CELLSPACING=1 CELLPADDING=1>
      <TR>
      <TD>&nbsp;<B>ID: $id</B></TD>
      <TD>&nbsp;<B>Nombre: $nombre</B></TD>
      <TD>&nbsp;<B>Nombre: $nombre</B></TD>
      <TD>&nbsp;<B>Fecha: $fecha</B>&nbsp;</TD>
      <TD>&nbsp;<B>Portada: $portada</B></TD>
      <TD>&nbsp;<B>Galeria: $galeria</B></TD>
      <TD>&nbsp;<B>Fotografo: $fotografo</B></TD></TR>
<?php      

   mysql_close
($link);   
?>
</table>
</body>
</html>
Código del Proceso
Código PHP:
<HTML>
<HEAD>
 <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="refresh" CONTENT="10;URL=fotos.php">

  <TITLE>Procesar</TITLE>

</HEAD>

<BODY>
<?php


  mysql_connect 
("localhost""root""pass");
  
mysql_select_db ("db_fotos");


  if (
mysql_query ("INSERT INTO galerias (id, nombre, fecha, portada, galeria, fotografo) values ('id','$nombre', '$fecha', '$portada', '$galeria', 'fotografo')"))
  {
    echo 
"";
  }
  else {
    echo 
mysql_error();
  }

?>
<?
    
echo "La galería fue agregada";
    
?>
</BODY>
</HTML>
3° Este sería el código que me genera al mostrar mi galería pero me gustaría que se ordenara por el id o número de la galería y que se paginara de 15 galerias en 15.

Código PHP:
<html>
<head>
   <title>Galeria de fotos</title>
</head>
<body>
<H1>Galeria de fotos</H1>
<?php
   
include("conexion.php");
   
$link=Conectarse();
?>
    <table border="0" width="406" id="table1">

<?php      

$result 
mysql_query("SELECT * FROM galerias ");
if (
$row mysql_fetch_array($result)) {
do{
    
$nombre $row[nombre];
    
$fecha $row[fecha];
    
$portada $row[portada];
    
$galeria $row[galeria];
    
$fotografo $row[fotografo];

echo 
"
        <tr>
            <td align=\"center\">
            <a href=\"$galeria\"><img border=\"0\" src=\"$portada\" alt=\"$nombre\"></a></td>
        </tr>
        <tr>
            <td align=\"center\">
            <p align=\"left\">Evento: $nombre</td>
        </tr>
        <tr>
            <td align=\"center\">
            <p align=\"left\">Fecha: $fecha</td>
        </tr>
        <tr>
            <td align=\"center\">
            <p align=\"left\">Fotos por: $fotografo</td>
        </tr>

      </tr> "
;
}
while(
$row mysql_fetch_array($result));
}
?>
</table>
</body>
</html>
Espero que me puedan ayudar.
  #2 (permalink)  
Antiguo 01/12/2005, 10:33
Avatar de helthon  
Fecha de Ingreso: junio-2005
Ubicación: Lima
Mensajes: 549
Antigüedad: 18 años, 10 meses
Puntos: 7
aun no se mucho de php pero lo que quieres puede ser esto

Código PHP:
$result mysql_query("SELECT * FROM galerias order by id DESC LIMIT 0 , 15  "); 

En cuanto a tu galeria tu solo subes los datos en tu formulario. porque no subes las imagenes tambien, eso lo realizas mendiante ftp?
__________________
HELTHON FUENTES
FLORERIA FLORES PERU Floresperu.com.pe
Garantizamos que cada entrega de flores será de la más alta calidad y frescura
  #3 (permalink)  
Antiguo 01/12/2005, 10:48
 
Fecha de Ingreso: junio-2005
Mensajes: 13
Antigüedad: 18 años, 10 meses
Puntos: 0
Gracias! funcionó muy bien, ahora espero poder paginar
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 02:31.