Estoy realizando un formulario en php con mysql, se trata de ver en pantalla los registros que están en la base de datos. La base de datos es con tablas relacionales. Pero me encuentro en un problema, se supone que el registro son los datos personales de doctores y cada uno de estos cuenta con más de un domicilio. Para la consulta hice lo siguiente:
consulta.php
Código PHP:
include('conexion.php');
$oper=$_SESSION['usuario'];
$consulta = mysqli_query($con, "SELECT m.*, u.*, d.* FROM medico m, usuarios u, domicilio d WHERE u.usuario='$oper' and m.id_medico = d.id_medico ORDER BY RAND() limit 1");
$registro = mysqli_fetch_object($consulta);
index.php
Código HTML:
<div class="registros-cinco" id=""> <tr> Apellido Paterno: <td width="335"><input type="text" value="<?php echo $registro->apellido_paterno;?>" placeholder="" id="apellido_paterno" style="width:150px;" name="apellido_paterno" onkeypress="return validarletras(event)" /></td> Apellido Materno: <td width="335"><input type="text" value="<?php echo $registro->apellido_materno;?>" placeholder="" id="apellido_materno" style="width:150px;" name="apellido_materno" onkeypress="return validarletras(event)"/></td> Primer Nombre: <td width="335"><input type="text" value="<?php echo $registro->nombre_1;?>" placeholder="" id="nombre_1" style="width:150px;" name="nombre_1" onkeypress="return validarletras(event)"/></td> Segundo Nombre: <td width="335"><input type="text" value="<?php echo $registro->nombre_2;?>" placeholder="" id="nombre_2" style="width:150px;" name="nombre_2" onkeypress="return validarletras(event)"/></td> </tr><br /><br /> <tr>
Código HTML:
<div class="registros-tres" id="agrega-registros-tres"> <label for="">Domicilio1</label><br /> <tr> Tipo de Vía : <td width="335"><select name="tipo_via" id="tipo_via"> <option value="<?php echo $registro->tipo_via;?>"><?php echo $registro->tipo_via;?></option> <?php while ($fila=mysqli_fetch_row($result_abrev_1)) { echo "<option value='".$fila['0']."'>".$fila['0']."</option>"; } ?> </select></td> Calle: <td width="335"><input type="text" value="<?php echo $registro->calle;?>" placeholder="" id="calle" name="calle"/></td> Número exterior: <td width="335"><input type="text" value="<?php echo $registro->numero_exterior;?>" style="width: 100px;" placeholder="" id="numero_exterior" name="numero_exterior"/></td> Número interior: <td width="335"><input type="text" value="<?php echo $registro->numero_interior;?>" style="width: 100px;" placeholder="" id="numero_interior" name="numero_interior"/></td> Referencia: <td width="335"><input type="text" value="<?php echo $registro->referencia;?>" placeholder="" id="referencia" name="referencia"/></td> </tr><br /><br /> <tr> Código Postal: <td width="335"><input type="text" value="<?php echo $registro->codigo_postal;?>" style="width: 50px;" placeholder="" id="codigo_postal" name="codigo_postal" minlength="5" maxlength="5" onkeypress="return justNumbers(event)"/></td> <td width="100"><button id="consultar" class="btn btn-primary" name="consultar" onclick="return validarCP();">...</button></td> Estado: <td width="335"><input type="text" value="<?php echo $registro->estado;?>" placeholder="" id="estado" name="estado" readonly="readonly"/></td> Municipio: <td width="335"><input type="text" value="<?php echo $registro->municipio;?>" placeholder="" id="municipio" name="municipio" readonly="readonly"/></td> Ciudad: <td width="335"><input type="text" value="<?php echo $registro->ciudad;?>" placeholder="" id="ciudad" name="ciudad" readonly="readonly"/></td> Colonia : <td width="335"><select name="colonia" id="colonia" style="width:200px;"> <option value="<?php echo $registro->colonia;?>"><?php echo $registro->colonia;?></option> <?php while ($fila=mysqli_fetch_row($sql_query)) { echo "<option value='".$fila['7']."'>".$fila['7']."</option>"; } ?> </select></td> </tr><br><br> <tr>
Código HTML:
<div class="registros-ocho" id="agrega-registros-diez"> <label for="">Domicilio2</label><br /> <tr> Tipo de Vía : <td width="335"><select name="tipo_via_2" id="tipo_via_2" > <option value="<?php echo $registro->tipo_via_2;?>"><?php echo $registro->tipo_via_2;?></option> <?php while ($fila=mysqli_fetch_row($result_abrev_2)) { echo "<option value='".$fila['0']."'>".$fila['0']."</option>"; } ?> </select></td> Calle: <td width="335"><input type="text" value="<?php echo $registro->calle;?>" placeholder="" id="calle_2" name="calle_2"/></td> Número exterior: <td width="335"><input type="text" value="<?php echo $registro->numero_exterior_2;?>" style="width: 100px;" placeholder="" id="numero_exterior_2" name="numero_exterior_2"/></td> Número interior: <td width="335"><input type="text" value="<?php echo $registro->numero_interior_2;?>" style="width: 100px;" placeholder="" id="numero_interior_2" name="numero_interior_2"/></td> Referencia: <td width="335"><input type="text" value="<?php echo $registro->referencia_2;?>" placeholder="" id="referencia_2" name="referencia_2"/></td> </tr><br/><br/> <tr> Código Postal: <td width="335"><input type="text" value="<?php echo $reg_cp->codigo_postal_2;?>" style="width: 50px;" placeholder="" id="codigo_postal_2" name="codigo_postal_2" minlength="5" maxlength="5" onkeypress="return justNumbers(event)"/></td> <td width="100"><button id="consultar_2" class="btn btn-primary" name="consultar_2" onclick="return validarCPD2();">...</button></td> Estado: <td width="335"><input type="text" value="<?php echo $reg_cp->estado_2;?>" placeholder="" id="estado_2" name="estado_2" readonly="readonly"/></td> Municipio: <td width="335"><input type="text" value="<?php echo $reg_cp->municipio_2;?>" placeholder="" id="municipio_2" name="municipio_2" readonly="readonly"/></td> Ciudad: <td width="335"><input type="text" value="<?php echo $reg_cp->ciudad_2;?>" placeholder="" id="ciudad_2" name="ciudad_2" readonly="readonly"/></td> Colonia : <td width="335"><select name="colonia_2" id="colonia_2" style="width:200px;"> <option value="<?php echo $reg_cp->colonia_2;?>"><?php echo $reg_cp->colonia_2;?></option> <?php while ($fila=mysqli_fetch_row($sql_queryDos)) { echo "<option value='".$fila['7']."'>".$fila['7']."</option>"; } ?> </select></td> </tr><br><br> <tr>
calle, numero_exterior, numero_interior, estado, municipio, ciudad y los componentes del domicilio 2 son calle_2, numero_exterior_2, numero_interior_2, estado_, municipio_2, ciudad_2.
No se como recuperarlos con el id de cada uno para poder enviarlos al domicilio 2.
Me pueden ayudar por favor?
Agradezco su apoyo