PHP - Popup al hacer click en un dato de una tabla

 
Vista:
sin imagen de perfil
Val: 22
Ha aumentado su posición en 2 puestos en PHP (en relación al último mes)
Gráfica de PHP

Popup al hacer click en un dato de una tabla

Publicado por Garikoitz (13 intervenciones) el 30/04/2018 22:38:39
Hola, ante todo muchas gracias a todo el mundo que me quiera ayudar.

Vereis, no soy programador ni he estudiado nada relacionado, tan sólo intento aprender por mi mismo. Con el método de investigar mucho prueba y error y como no con la ayuda de los foros.

Tengo una lista en la que muestro id y fecha de solicitud, quisiera que al hacer click en id se me muestren mas detalles del pedido.

Algo tengo hecho que he buscado por internet, pero no me funciona.

Ficheros con el codigo mostrar-2.php, tambien los he dejado adjuntados.

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
<?php
 
	//Conectamos con el Servidor con los datos guardados en config.php
$connection = mysqli_connect('localhost', 'root', '');
if (!$connection){
    die("Fallo la conexion con la base de datos" . mysqli_error($connection));
}
 
 
 
// Conecta con la Base de Datos 
 
$select_db = mysqli_select_db($connection, 'albaranes');
if (!$select_db){
    die("Database seleccionada ha fallado" . mysqli_error($connection));
}
 
 ?>
 
 
<!DOCTYPE html>
<html>
<head>
	<title>Pedidos Realizados</title>
 
	<!--  Carga de Librerias  -->
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    	<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
	<!-- Fin de Carga de Librerias-->
 
</head>
<body>
 
<br>
 
<div class="container">
	<div class="table-responsive table-hover">
	<table class="table" >
		<thead>
			<th>Nยบ Pedido</th>
			<th>Fecha Solicitud</th>
		</thead>
 
		<?php
		$sql="SELECT * from solicitud_material";
		$result=mysqli_query($connection,$sql);
 
		while($mostrar=mysqli_fetch_array($result)){
		 ?>
 
		<tr>
			<td><a href="popup.php" target="_blank" onclick="window.open(this.href,this.target,'width=1000,height=650,top=200,left=200,toolbar=no,location=no,status=no,resizable=yes,menubar=no');return false;"><?php echo $mostrar['id'] ?></a></td>
			<td><?php echo $mostrar['fecha_solicitud'] ?></td>
		</tr>
	<?php
	}
	 ?>
	</table>
	</div>
</div>
 
	<!--  Carga de Librerias  -->
		<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
	<!-- Fin de Carga de Librerias-->
 
</body>
</html>

Codigo del popup.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
 
	//Conectamos con el Servidor con los datos guardados en config.php
$connection = mysqli_connect('localhost', 'root', '');
if (!$connection){
    die("Fallo la conexion con la base de datos" . mysqli_error($connection));
}
 
 
 
// Conecta con la Base de Datos 
 
$select_db = mysqli_select_db($connection, 'albaranes');
if (!$select_db){
    die("Database seleccionada ha fallado" . mysqli_error($connection));
}
 
 ?>
 
 
<!DOCTYPE html>
<html>
<head>
	<title>Pedidos Realizados</title>
 
	<!--  Carga de Librerias  -->
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    	<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
	<!-- Fin de Carga de Librerias-->
 
</head>
<body>
 
<br>
 
<div class="container">
	<div class="table-responsive table-hover">
	<table class="table" >
		<thead>
			<th>id</th>
			<th>Fecha Solicitud</th>
			<th>C.C. Solicitante</th>
			<th>Turno</th>
			<th>Línea</th>
			<th>Punto de Entrega</th>
			<th>Matrícula</th>
			<th>Denominación</th>
			<th>Referencia</th>
			<th>Cantidad</th>
		</thead>
 
 
 
		<!--  

		<?php 
		$sql="SELECT * from solicitud_material";
		$result=mysqli_query($connection,$sql);

		while($mostrar=mysqli_fetch_array($result)){
		 ?>

		-->
 
 
		<?php
		$id = $_GET['id'];
		$sql="SELECT * from solicitud_material" WHERE id = ".$id;
		$result=mysqli_query($connection,$sql) or die(mysql_error());

		while($mostrar=mysqli_fetch_array($result)){
		 ?>

		<tr>
			<td><?php echo $mostrar['id'] ?></td>
			<td><?php echo $mostrar['fecha_solicitud'] ?></td>
			<td><?php echo $mostrar['cc_solicitante'] ?></td>
			<td><?php echo $mostrar['turno'] ?></td>
			<td><?php echo $mostrar['linea'] ?></td>
			<td><?php echo $mostrar['punto_entrega'] ?></td>
			<td><?php echo $mostrar['matricula'] ?></td>
			<td><?php echo $mostrar['denominacion'] ?></td>
			<td><?php echo $mostrar['referencia'] ?></td>
			<td><?php echo $mostrar['cantidad'] ?></td>
		</tr>
	<?php 
	}
	 ?>
	</table>
	</div>
</div>

	<!--  Carga de Librerias  -->
		<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
	<!-- Fin de Carga de Librerias-->

</body>
</html>

Base de datos por si alguien quiere hacer pruebas y aprender como yo.

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
-- phpMyAdmin SQL Dump
-- version 4.7.4
-- https://www.phpmyadmin.net/
--
-- Servidor: 127.0.0.1:3306
-- Tiempo de generación: 28-04-2018 a las 22:07:47
-- Versión del servidor: 5.7.19
-- Versión de PHP: 7.0.23
 
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
 
 
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
 
--
-- Base de datos: `albaranes`
--
 
-- --------------------------------------------------------
 
--
-- Estructura de tabla para la tabla `solicitud_material`
--
 
DROP TABLE IF EXISTS `solicitud_material`;
CREATE TABLE IF NOT EXISTS `solicitud_material` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `fecha_solicitud` date DEFAULT NULL,
  `cc_solicitante` varchar(70) DEFAULT NULL,
  `turno` varchar(50) DEFAULT NULL,
  `linea` varchar(350) DEFAULT NULL,
  `punto_entrega` varchar(100) DEFAULT NULL,
  `matricula` varchar(100) DEFAULT NULL,
  `denominacion` varchar(200) DEFAULT NULL,
  `referencia` varchar(100) DEFAULT NULL,
  `cantidad` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
 
--
-- Volcado de datos para la tabla `solicitud_material`
--
 
INSERT INTO `solicitud_material` (`id`, `fecha_solicitud`, `cc_solicitante`, `turno`, `linea`, `punto_entrega`, `matricula`, `denominacion`, `referencia`, `cantidad`) VALUES
(1, '2018-04-19', '1131', 'T1', 'L141', '16 Planta Alta', '63213', 'Portacapsulas', '108401', '1');
COMMIT;
 
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
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 santi
Val: 588
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Popup al hacer click en un dato de una tabla

Publicado por santi (204 intervenciones) el 01/05/2018 00:39:52
Hola,

antes que nada, viendo que estás utilizando bootstrap podrías utilizar la función de modal para mostrar el popup -> https://getbootstrap.com/docs/3.3/javascript/#modals

A parte de esto, si lo abres en una ventana nueva con target="_blank" puedes quitar el atributo de onclick y añadir el id en la url del href:

1
<a href="popup.php?id=<?php echo $mostrar['id'] ?>" target="_blank"><?php echo $mostrar['id'] ?></a>

Entonces desde el popup lo recibes igual como $_GET:

1
2
3
4
5
if($_GET['id'])
{
    $id = $_GET['id'];//aquí está el valor del id
    //... consulta
}

Prueba a ver ;)
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
sin imagen de perfil
Val: 22
Ha aumentado su posición en 2 puestos en PHP (en relación al último mes)
Gráfica de PHP

Popup al hacer click en un dato de una tabla

Publicado por Garikoitz (13 intervenciones) el 01/05/2018 07:56:44
Ante todo muchas gracias.

El popup se abre, pero no muestra nada, porque como te indico mas abajo el popup da error en la linea 75 del popup.php.

Veamos, lo he dejado así el mostrar-2.php, siguiendo tus indicaciones, o eso he intentado vamos.

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
<?php
 
	//Conectamos con el Servidor con los datos guardados en config.php
$connection = mysqli_connect('localhost', 'root', '');
if (!$connection){
    die("Fallo la conexion con la base de datos" . mysqli_error($connection));
}
 
 
 
// Conecta con la Base de Datos 
 
$select_db = mysqli_select_db($connection, 'albaranes');
if (!$select_db){
    die("Database seleccionada ha fallado" . mysqli_error($connection));
}
 
 ?>
 
 
<!DOCTYPE html>
<html>
<head>
	<title>Pedidos Realizados</title>
 
	<!--  Carga de Librerias  -->
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    	<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
	<!-- Fin de Carga de Librerias-->
 
</head>
<body>
 
<br>
 
<div class="container">
	<div class="table-responsive table-hover">
	<table class="table" >
		<thead>
			<th>Nº Pedido</th>
			<th>Fecha Solicitud</th>
		</thead>
 
		<?php
		$sql="SELECT * from solicitud_material";
		$result=mysqli_query($connection,$sql);
 
		while($mostrar=mysqli_fetch_array($result)){
		 ?>
 
		<tr>
			<td><a href="popup.php?id=<?php echo $mostrar['id'] ?>" target="_blank"><?php echo $mostrar['id'] ?></a></td>
			<td><?php echo $mostrar['fecha_solicitud'] ?></td>
		</tr>
	<?php
	}
	 ?>
	</table>
	</div>
</div>
 
	<!--  Carga de Librerias  -->
		<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
	<!-- Fin de Carga de Librerias-->
 
</body>
</html>

El archivo popup.php me da error en la linea 75, que es esta, a esa linea me he dado cuenta que le faltaban unas comillas, pero aun asi me sigue dando error:

1
$sql="SELECT * from solicitud_material" WHERE id = ".$id";

El codigo entero del popup lo deje asi, siguiendo tus instrucciones, o eso he intentado.

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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
 
	//Conectamos con el Servidor con los datos guardados en config.php
$connection = mysqli_connect('localhost', 'root', '');
if (!$connection){
    die("Fallo la conexion con la base de datos" . mysqli_error($connection));
}
 
 
 
// Conecta con la Base de Datos 
 
$select_db = mysqli_select_db($connection, 'albaranes');
if (!$select_db){
    die("Database seleccionada ha fallado" . mysqli_error($connection));
}
 
 ?>
 
 
<!DOCTYPE html>
<html>
<head>
	<title>Pedidos Realizados</title>
 
	<!--  Carga de Librerias  -->
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    	<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
	<!-- Fin de Carga de Librerias-->
 
</head>
<body>
 
<br>
 
<div class="container">
	<div class="table-responsive table-hover">
	<table class="table" >
		<thead>
			<th>id</th>
			<th>Fecha Solicitud</th>
			<th>C.C. Solicitante</th>
			<th>Turno</th>
			<th>Línea</th>
			<th>Punto de Entrega</th>
			<th>Matrícula</th>
			<th>Denominación</th>
			<th>Referencia</th>
			<th>Cantidad</th>
		</thead>
 
 
 
		<!--  

		<?php 
		$sql="SELECT * from solicitud_material";
		$result=mysqli_query($connection,$sql);

		while($mostrar=mysqli_fetch_array($result)){
		 ?>

		-->
 
 
		<?php
		if($_GET['id'])
 
{
 
    $id = $_GET['id'];//aquí está el valor del id
 
 	//... consulta
 
		$sql="SELECT * from solicitud_material" WHERE id = ".$id";
		$result=mysqli_query($connection,$sql) or die(mysql_error());
}
		while($mostrar=mysqli_fetch_array($result)){
		 ?>
 
		<tr>
			<td><?php echo $mostrar['id'] ?></td>
			<td><?php echo $mostrar['fecha_solicitud'] ?></td>
			<td><?php echo $mostrar['cc_solicitante'] ?></td>
			<td><?php echo $mostrar['turno'] ?></td>
			<td><?php echo $mostrar['linea'] ?></td>
			<td><?php echo $mostrar['punto_entrega'] ?></td>
			<td><?php echo $mostrar['matricula'] ?></td>
			<td><?php echo $mostrar['denominacion'] ?></td>
			<td><?php echo $mostrar['referencia'] ?></td>
			<td><?php echo $mostrar['cantidad'] ?></td>
		</tr>
	<?php
	}
	 ?>
	</table>
	</div>
</div>
 
	<!--  Carga de Librerias  -->
		<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
	<!-- Fin de Carga de Librerias-->
 
</body>
</html>
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
sin imagen de perfil
Val: 22
Ha aumentado su posición en 2 puestos en PHP (en relación al último mes)
Gráfica de PHP

Popup al hacer click en un dato de una tabla

Publicado por Garikoitz (13 intervenciones) el 01/05/2018 12:10:21
He encontrado el fallo de la linea 75.

Me indicaste esto:

1
$sql="SELECT * from solicitud_material" WHERE id = ".$id";

Y yo creo que debería de ser así, de hecho ya no me da fallo en esa linea 75.

1
$sql="SELECT * from solicitud_material WHERE id ='.$id'";

Pero me sigue sin funcionar, me da error ahora en la linea 108 que es:

1
</html>

Y me indica el siguiente fallo:

1
Parse error: syntax error, unexpected end of file in C:\wamp64\www\albaranes\php\popup.php on line 108

Añado el codigo completo:

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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
 
	//Conectamos con el Servidor con los datos guardados en config.php
$connection = mysqli_connect('localhost', 'root', '');
if (!$connection){
    die("Fallo la conexion con la base de datos" . mysqli_error($connection));
}
 
 
 
// Conecta con la Base de Datos 
 
$select_db = mysqli_select_db($connection, 'albaranes');
if (!$select_db){
    die("Database seleccionada ha fallado" . mysqli_error($connection));
}
 
 ?>
 
 
<!DOCTYPE html>
<html>
<head>
	<title>Pedidos Realizados</title>
 
	<!--  Carga de Librerias  -->
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    	<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
	<!-- Fin de Carga de Librerias-->
 
</head>
<body>
 
<br>
 
<div class="container">
	<div class="table-responsive table-hover">
	<table class="table" >
		<thead>
			<th>Nº Pedido</th>
			<th>Fecha Solicitud</th>
			<th>C.C. Solicitante</th>
			<th>Turno</th>
			<th>Línea</th>
			<th>Punto de Entrega</th>
			<th>Matrícula</th>
			<th>Denominación</th>
			<th>Referencia</th>
			<th>Cantidad</th>
		</thead>
 
 
 
		<!--  

		<?php 
		$sql="SELECT * from solicitud_material";
		$result=mysqli_query($connection,$sql);

		while($mostrar=mysqli_fetch_array($result)){
		 ?>

		-->
 
 
		<?php
		if($_GET['id'])
 
{
 
    $id = $_GET['id'];//aquí está el valor del id
}
 	//... consulta
 
		$sql="SELECT * from solicitud_material WHERE id ='.$id'";
		$result=mysqli_query($connection,$sql) or die(mysql_error());
 
		while($mostrar=mysqli_fetch_array($result)){
		 ?>
 
		<tr>
			<td><?php echo $mostrar['id'] ?></td>
			<td><?php echo date("d-m-Y  H:i", strtotime($mostrar['fecha_solicitud'])) ?></td>
			<!--<td><?php echo $mostrar['fecha_solicitud'] ?></td>-->
			<td><?php echo $mostrar['cc_solicitante'] ?></td>
			<td><?php echo $mostrar['turno'] ?></td>
			<td><?php echo $mostrar['linea'] ?></td>
			<td><?php echo $mostrar['punto_entrega'] ?></td>
			<td><?php echo $mostrar['matricula'] ?></td>
			<td><?php echo $mostrar['denominacion'] ?></td>
			<td><?php echo $mostrar['referencia'] ?></td>
			<td><?php echo $mostrar['cantidad'] ?></td>
		</tr>
	<?php
	}
	 ?>
	</table>
	</div>
</div>
 
	<!--  Carga de Librerias  -->
		<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
	<!-- Fin de Carga de Librerias-->
 
</body>
</html>

Y la base de datos si alguien quiere hacer pruebas

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
-- phpMyAdmin SQL Dump
-- version 4.7.4
-- https://www.phpmyadmin.net/
--
-- Servidor: 127.0.0.1:3306
-- Tiempo de generación: 01-05-2018 a las 08:08:58
-- Versión del servidor: 5.7.19
-- Versión de PHP: 7.0.23
 
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
 
 
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
 
--
-- Base de datos: `albaranes`
--
 
-- --------------------------------------------------------
 
--
-- Estructura de tabla para la tabla `solicitud_material`
--
 
DROP TABLE IF EXISTS `solicitud_material`;
CREATE TABLE IF NOT EXISTS `solicitud_material` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `fecha_solicitud` datetime DEFAULT NULL,
  `cc_solicitante` varchar(70) DEFAULT NULL,
  `turno` varchar(50) DEFAULT NULL,
  `linea` varchar(350) DEFAULT NULL,
  `punto_entrega` varchar(100) DEFAULT NULL,
  `matricula` varchar(100) DEFAULT NULL,
  `denominacion` varchar(200) DEFAULT NULL,
  `referencia` varchar(100) DEFAULT NULL,
  `cantidad` varchar(50) DEFAULT NULL,
  `material_entregado` varchar(50) DEFAULT NULL,
  `estado` varchar(50) DEFAULT NULL,
  `fecha_tramitado` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;
 
--
-- Volcado de datos para la tabla `solicitud_material`
--
 
INSERT INTO `solicitud_material` (`id`, `fecha_solicitud`, `cc_solicitante`, `turno`, `linea`, `punto_entrega`, `matricula`, `denominacion`, `referencia`, `cantidad`, `material_entregado`, `estado`, `fecha_tramitado`) VALUES
(1, '2018-04-19 00:00:00', '1131', 'T1', 'L141', '16 Planta Alta', '63213', 'Portacapsulas', '108401', '1', NULL, 'Pendiente', NULL),
(2, '2018-04-13 00:00:00', '1131', 'T1', 'L141', '16 Planta Alta', '63213', 'Portacapsulas', '108401', '1', NULL, 'Pendiente', NULL),
(3, '2018-04-13 00:00:00', '1131', 'T1', 'L141', '16 Planta Alta', '63213', 'Portacapsulas', '108401', '1', NULL, 'Pendiente', NULL),
(4, '2018-04-05 00:00:00', '1152', 'T2', 'L150', '15 Planta Baja', '52415', 'Capsula', '105426', '2', NULL, 'Pendiente', NULL),
(5, '2018-04-29 00:00:00', '1523', 'T3', '1524', '15 Planta baja', '56896', 'racor', '125478', '5', NULL, 'Pendiente', NULL),
(6, '2018-04-30 19:08:38', '1212', 'T1', '152', 'Planta Media', '65896', 'Manguera', '4568989', '5', NULL, 'Validado', NULL),
(7, '2018-04-30 19:10:39', '585', 'T1', '157', 'Planta Media', '65896', 'Manguera Corta', '45689', '4', NULL, 'Pendiente', NULL),
(8, '2018-05-01 05:28:05', '5555', 'T1', '65656', 'Planta baja Media', '5656565', 'Cable 2 m acodado', '452365', '2', NULL, 'Pendiente', NULL),
(9, '2018-05-01 05:28:05', '5555', 'T1', '65656', 'Planta baja Media', '5656565', 'Sarten', '565656', '5', NULL, 'Tramitado', NULL),
(10, '2018-05-01 06:57:16', '585585', 'T1', '65656', 'Planta estado', '56896', 'Estado racores', '56568', '3', NULL, 'Pendiente', NULL),
(11, '2018-05-01 06:57:16', '585585', 'T1', '65656', 'Planta estado', '56896', 'Estado racores', '56568', '5', NULL, 'Pendiente', NULL);
COMMIT;
 
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
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
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

Popup al hacer click en un dato de una tabla

Publicado por xve (6935 intervenciones) el 01/05/2018 21:08:14
Hola, el sql tiene que ser así:

1
$sql="SELECT * from solicitud_material WHERE id =".$id;

El $id no tiene que ir entre comillas, ya que es un valor numerico.
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