PHP - administrador de imagenes

 
Vista:
sin imagen de perfil

administrador de imagenes

Publicado por jhonatan (4 intervenciones) el 22/02/2016 22:18:28
necesito ayuda para un administrador de imágenes que tengo, les explico:

en el administrador primeramente se crea una galeria y al ingresar el nombre todo sale bien pero el problema es cuando lo trato de editar, no lo hace, ni tampoco lo elimina.

en la parte de subir imagenes a cada galeria tengo muchos errores como son: al subir una imagen no me la visualiza pero se registra en la BD, aparece como imagen rota, de ahi quiero agregar varias a la ves pero solo me sube una, tiene la opcion para eliminar y poner "insivible" para no visualizarla en la parte del usuario pero tampoco funciona.

en la parte del usuario tengo 2 apartados (albumnes e invitados especiales) donde quisiera visualizar imagenes pero no busco como hacer para que visualice en el otro apartado sin que tenga conflictos, igual no se visualizan las imagenes.

este es mi codigo:

para crear galerias aunque igual me gustaria que de la opcion de escojer una imagen para cada galeria

panel.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
include ('cnx.php');
$consulta =<<<SQL
SELECT
   IDGALERIA,
   TITULO,
   DESCRIPCION,
  DATE_FORMAT(NOW(FECHA_ALTA), '%d/%m/%Y %h:%i %p') as FECHA_ALTA
FROM
 galerias
SQL;
$filas = mysqli_query($cnx, $consulta);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MANEJO DE GALERIAS</title>
</head>
<body>
	<h1>panel de control</h1>
	<h2>listado de galerias</h2>
 
    <div><a href="nueva_galeria.php">cargar una nueva galeria</a></div>
	<table border="1">
	<tr>
		<th>nombre</th>
		<th>descripcion</th>
		<th>fecha alta</th>
		<th>botones de accion</th>
    </tr>
    <?php
	while ($columna = mysqli_fetch_assoc($filas)){
		echo"<tr>";
		echo"<td>$columna[TITULO]</td>";
		echo"<td>$columna[DESCRIPCION]</td>";
		echo"<td>$columna[FECHA_ALTA]</td>";
		echo"<td><a href='editar_galeria.php?id=$columna[IDGALERIA]'>editar</a>|<a href='borrar_galeria.php?id=$columna[IDGALERIA]'>borrar</a>  | <a href='administrar_fotos.php?id=$columna[IDGALERIA]'>adminsitrar fotos</a></td>";
		echo"</tr>";
		}
	?>
</table>
</body>
</html>



nueva_galeria.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
label {display: block;}
textarea {display: block;}
</style>
</head>
<body>
	<form method="post" action="guardar_galeria.php">
	    <label>titulo</label>
	    <input type="text" name="titulo" />
	    <label>descripcion</label>
	    <textarea name="descripcion" rows="5" cols="90"></textarea>
	    <input type="submit" />
    </form>
</body>
</html>



modificar_galeria.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
include ('cnx.php');
 
$titulo = $_POST['titulo'];
$descripcion = $_POST['descripcion'];
$id = $_POST['idgaleria'];
 
$consulta =<<<SQL
UPDATE
   galerias
  SET
   TITULO='$titulo',
   DESCRIPCION='$descripcion',
 
 
 WHERE
   IDGALERIA ='$id'
 
SQL;
mysqli_query ($cnx, $consulta);
 
header("location: panel.php");
 
?>


guardar_galeria.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
include('cnx.php');
 
$titulo=$_POST['titulo'];
$descripcion=$_POST['descripcion'];
 
$consulta =<<<SQL
INSERT INTO
   galerias
  SET
   TITULO='$titulo',
   DESCRIPCION='$descripcion',
   FECHA_ALTA = NOW()
SQL;
mysqli_query ($cnx, $consulta);
 
header("location: panel.php");
 
?>


editar_galeria.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
include ('cnx.php');
$id=$_GET ['id'];
 
$consulta=<<<SQL
SELECT TITULO, DESCRIPCION
FROM galerias WHERE IDGALERIA = '$id'
LIMIT 1
SQL;
 
$filas = mysqli_query($cnx, $consulta);
$columna = mysqli_fetch_assoc($filas);
 
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
label {display: block;}
textarea {display: block;}
</style>
</head>
<body>
	<form method="post" action="modificar_galeria.php">
	    <label>titulo</label>
	    <input type="text" name="titulo" value="<?php echo $columna['TITULO']?>" />
	    <label>descripcion</label>
	    <textarea name="descripcion" rows="5" cols="90"><?php echo $columna['DESCRIPCION']?></textarea>
	    <input type="hidden" name="idgaleria" value="<?php echo $id; ?>"/>
	    <input type="submit" />
    </form>
 
 
 
</body>
</html>


borrar_galeria.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
if (isset($_GET['id'])) {
	include ('cnx.php');
	$consulta=<<<SQL
 
	DELETE FROM galerias
		WHERE IDGALERIA='$id'
		LIMIT 1
SQL;
 mysqli_query ($cnx, $consulta);
}
 
header ("location: panel.php");
 
?>


para subir y administrar las imagenes en cada galeria

administrar_fotos_upload.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
include('cnx.php');
 
$nombre = $_POST ['nombre'];
$fkgaleria = $_POST ['idgaleria'];
$estado = 'visible';
$nombre_file = mktime() .'.png';
$posicion = 0;
 
$consulta = <<<SQL
 INSERT INTO
   fotos
  SET
    NOMBRE='$nombre',
	ARCHIVO='$nombre_file',
	ESTADO='$estado',
	POSICION='$posicion',
	FKGALERIA='$fkgaleria'
SQL;
 
mysqli_query ($cnx,$consulta);
 
$original = $_FILES['tmp_name'][$indice];
$destino= "fotos/$nombre_file";
move_uploaded_file ($original,$destino);
 
header ("location: administrar_fotos.php?id=fkgaleria");
?>



administrar_fotos_ordenar.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
include ('cnx.php');
$idgaleria = $_POST['idgaleria'];
 
foreach($_POST['posicion'] as $numero=>$idfoto){
$nuevo_estado = $_POST['estado'] [$numero];
 
if ($nuevo_estado == 'borrar'){
 
$filename = $_POST['filename'] [$numero];
 
$consulta=<<<SQL
	DELETE FROM fotos WHERE IDFOTO='$idfoto' LIMIT 1
SQL;
}
mysqli_query($cnx, $consulta);
}
 
header("Location: administrar_fotos.php?id=$idgaleria");
?>


administrar_fotos.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
include('cnx.php');
$id = $_GET['id'];
 
$consulta=<<<SQL
SELECT
         IDFOTO,
         ARCHIVO,
         NOMBRE,
         ESTADO
 FROM
         fotos
 WHERE
    FKGALERIA='$id'
ORDER BY
     POSICION ASC
SQL;
$filas = mysqli_query($cnx, $consulta);
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
.fotito {
	display: inline-block; border: 1px solid #333; margin:4px; padding: 0 6px;}
	.invisible {
		background:#ddd;}
textarea {display: block;}
</style>
<title>Documento sin título</title>
</head>
<body>
<h1>panel de control</h1>
<h2>administracion de fotos</h2>
 
<h3> ordernar las fotos</h3>
<a href="panel.php">VOLVER</a>
 <br />
 
 
<?php
while ($columna = mysqli_fetch_assoc ($filas)){
	echo '<div class="fotito '.$columna['ESTADO'].'">';
	echo "<p>$columna[NOMBRE]</p>";
	echo"<div> <select><option>visible</option><option";
	if($columna['ESTADO'] == 'invisible'){echo'selected="selected"';}
	echo">invisible</option><option>borrar</option></select></div>";
	echo "<img src='fotos/$columna[ARCHIVO]' height= '100' />";
	echo "<input type='hidden' name='filename' value='$columna[ARCHIVO]' />";
	echo '</div>';
	}
?>
<hr />
 <form method="post" enctype="multipart/form-data" action="administrar_fotos_upload.php">
 <input type="hidden" name="idgaleria" value="<?php echo $id; ?>" />
 
 
 <div id="inputs_file">
    <div>
       <label>titulo</label>
       <input type="text" name="titulo" />
       <label>archivo</label>
       <input type="file" name="archivo" multiple="multiple" />
    </div>
 </div>
 <input type="submit" value="agregar fotos" />
 </form>
 <br />
 <a href="panel.php">VOLVER</a>
 
</body>
</html>




ayuda porfaaaaaaa D:
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

administrador de imagenes

Publicado por xve (6935 intervenciones) el 23/02/2016 08:33:08
Hola Jonathan, la verdad es que veo mucho código, y muchas dudas o preguntas, y no se muy bien por donde empezar a mirar...;(

Una manera sencilla, para que a la gente no le cueste responderte, es que hagas preguntas concretas y muestres la parte del código a la que hace referencia para que la podamos probar.... muchas preguntas no muy concretas, y tanto código, dudo que nadie se ponga a revisar-lo todo.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar