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.
Codigo del popup.php
Base de datos por si alguien quiere hacer pruebas y aprender como yo.
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 */;
- popup.rar(3,3 KB)
Valora esta pregunta


0