- Les comento, yo tengo una grilla que trae de mi base de datos un par de datos pertinentes a una edicion de revista, entre ellos el dato ID_EDICION.
- La grilla se carga con todas las revistas que tengan ediciones existentes
- Al hacer click en el icono de la lupa, me muestra las secciones de esa edicion
Lo que yo necesito es que al hacer click en la lupa e irme al modal correspondiente de alguna manera me pueda enviar el ID_EDICION correspondiente a los datos de esa fila.
Les muestro mi codigo
index.php
Código PHP:
<?php session_start(); ?>
<!DOCTYPE html>
<html lang="es">
<head>
<?php require_once("inc/header.php");?>
</head>
<body>
<?php require_once("inc/cabecera.php"); ?>
<?php require_once("inc/conexionObj.php") ?>
<div class="container">
<div class="row">
<div class="box">
<center>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#crearRevista">Crear revista</button>
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#crearEdicion">Crear Edicion</button>
</center>
<br />
<table class="table table-hover">
<thead class="cabecera_tabla ">
<td class="letra_negra active"><center><strong>REVISTA</strong></center></td>
<td class="letra_negra active"><center><strong>EDICION</strong></center></td>
<td class="letra_negra active"><center><strong>DESCRIPCION</strong></center></td>
<td class="letra_negra active"><center><strong>ULTIMA MODIFICACION</strong></center></td>
<td class="letra_negra active"><center><strong>SECCIONES</strong></center></td>
</thead>
<?php
$db = new mysqli($databaseHost, $databaseUser, $databasePass, $databaseName);
$consulta = $db->query("SELECT * FROM edicion");
while($dato = $consulta->fetch_object()) {
$nombreRevista = $db->query("SELECT NOMBRE FROM revista WHERE ID_REVISTA = $dato->ID_REVISTA");
$revista = $nombreRevista->fetch_object();
?>
<tr class="cabecera_tabla active">
<td class="letra_negra"><?php echo "$revista->NOMBRE"; ?></td>
<td class="letra_negra"><?php echo "$dato->ID_EDICION"; ?></td>
<td class="letra_negra"><?php echo "$dato->DESCRIPCION"; ?></td>
<td class="letra_negra"><?php echo "$dato->FECHA_MODIFICACION"; ?></td>
<td><button type="button" class="btn btn-warning" data-toggle="modal" data-target="#verSecciones"><span class="glyphicon glyphicon-search" alt="Ver Secciones"></span></button></td>
</tr>
<?php
$_SESSION['idSesion'] = $dato->ID_EDICION;
}?>
</table>
</div>
</div>
</div>
<?php
require_once("inc/modales/verSeccion.php"); // Modal para ver Secciones
require_once("inc/footer.php"); // Trae el footer
?>
</body>
</html>
}
y esta es la hoja de mi modal, que se encuentra incrusatada en el mismo php
Código PHP:
<?php
require_once("inc/conexion.php");
require_once("inc/header.php");
require_once("inc/systemVariables.php");
//$idCone = conexion();
?>
<div id="verSecciones" class="modal fade " role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button><br>
<div class="panel panel-default">
<div class="panel-body">
<center>
<h4 class="modal-title">
SECCIONES DE LA REVISTA
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-chevron-down"></span> </button>
<ul class="dropdown-menu" role="menu">
<li><a href="#" data-toggle="modal" data-target="#crearSeccion">Nueva Seccion</a></li>
<li><a href="#" data-toggle="modal" data-target="#crearNota">Nueva Nota</a></li>
</ul>
</div>
</h4>
</center>
</div>
</div>
</div>
<div class="modal-body">
<div class="panel panel-info"><div class="panel-heading"><center><h4><?php echo $_SESSION['idSesion']; ?></h4></center></div>
<table class="table">
<thead class="cabecera_tabla">
<td class="letra_negra"><center><strong>Nombre de la nota</strong></center></td>
<td class="letra_negra"><center><strong>Ultima Modifiacion</strong></center></td>
<td class="letra_negra"><center><strong>Editar</strong></center></td>
<td class="letra_negra"><center><strong>Eliminar</strong></center></td>
</thead>
<tr class="cabecera_tabla">
<td class="letra_negra">Messi ya juega</td>
<td class="letra_negra"> --- </td>
<td class="letra_negra"><button type="input" class="btn btn-warning" data-toggle="modal" data-target="#verSecciones"><span class="glyphicon glyphicon-pencil" alt="Ver Secciones"></span></button></td>
<td class="letra_negra"><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#verSecciones"><span class="glyphicon glyphicon-remove" alt="Ver Secciones"></span></button></td>
</tr>
<tr class="cabecera_tabla">
<td class="letra_negra">El circo de la AFA</td>
<td class="letra_negra"><span class="label label-default">31/05/2016 15:33</span> <span class="label label-warning">Juan228</span></td>
<td class="letra_negra"><button type="button" class="btn btn-warning" data-toggle="modal" data-target="#verSecciones"><span class="glyphicon glyphicon-pencil" alt="Ver Secciones"></span></button></td>
<td class="letra_negra"><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#verSecciones"><span class="glyphicon glyphicon-remove" alt="Ver Secciones"></span></button></td>
</tr>
</table>
</div>
<div class="panel panel-info"><div class="panel-heading"><center><h4>TENIS</h4></center></div>
<table class="table">
<thead class="cabecera_tabla">
<td class="letra_negra"><center><strong>Nombre de la nota</strong></center></td>
<td class="letra_negra"><center><strong>Ultima Modificacion</strong></center></td>
<td class="letra_negra"><center><strong>Editar</strong></center></td>
<td class="letra_negra"><center><strong>Eliminar</strong></center></td>
</thead>
<tr class="cabecera_tabla">
<td class="letra_negra">Nadal a la final</td>
<td class="letra_negra"><span class="label label-default">28/05/2016 18:32</span> <span class="label label-warning">German</span></td>
<td class="letra_negra"><button type="button" class="btn btn-warning" data-toggle="modal" data-target="#verSecciones"><span class="glyphicon glyphicon-pencil" alt="Ver Secciones"></span></button></td>
<td class="letra_negra"><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#verSecciones"><span class="glyphicon glyphicon-remove" alt="Ver Secciones"></span></button></td>
</tr>
<tr class="cabecera_tabla">
<td class="letra_negra">Federer eliminado en cuartos</td>
<td class="letra_negra"><span class="label label-default">23/04/2016 09:15</span> <span class="label label-warning">Brian</span> </td>
<td class="letra_negra"><button type="button" class="btn btn-warning" data-toggle="modal" data-target="#verSecciones"><span class="glyphicon glyphicon-pencil" alt="Ver Secciones"></span></button></td>
<td class="letra_negra"><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#verSecciones"><span class="glyphicon glyphicon-remove" alt="Ver Secciones"></span></button></td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
Lo unico que logre hacer es que al final de cada fila me guarde en una variable de session el numero de la ID_EDICION, pero logicamente, cuando carga la proxima fila me lo pisa..