Pagina index.php
Código PHP:
<?php
// Conexión a la base de datos
$bd_host = "localhost";
$bd_usuario = "root";
$bd_password = "";
$bd_base = "asesoria";
$con = mysql_connect($bd_host, $bd_usuario, $bd_password);
if(!$con){
echo "Error al conectar a la Base de Datos.";
}
mysql_select_db($bd_base, $con) or die("No pudo seleccionarse la Base de Datos.");
?>
<?php
$sql = "SELECT * FROM sociedades ORDER BY 'nombre'"; // Obtiene todas las sociedades almacenadas en la base de datos
$rs = mysql_query($sql, $con) or die("Error al consultar datos sociedades: ".mysql_error());
if(mysql_num_rows($rs)>0)
{
$tam=mysql_num_rows($rs);
while($row = mysql_fetch_assoc($rs))
{
$id_soci[]=$row["id_soci"];
$sociedades[]=$row["nombre"];
}
}
mysql_close($con);
?>
<html>
<table align="center" cellspacing="2" cellpadding="2" border="0">
<tr>
<td rowspan="14" width="1" height="100%">
<img border="0" src="transparente.gif" id="imagenAltaRuta" name="imagenAltaRuta" width="1" height="100%">
</td>
</tr>
<tr>
<td align="right">
<b>Seleecione la sociedad que desee:</b>
</td>
<td>
<select name="pob1">
<option value="">____________________________
<?php
for($i=0; $i<$tam; $i++){
?>
<option value="<?php echo $id_soci[$i] ?>"><?php echo $sociedades[$i] ?>
<?php
}
?>
</select>
</td>
</tr>
<tr align="center">
<td>
<BR>
<input type="submit" value="ACEPTAR" onFocus="this.blur()">
</td>
</tr>
</table>
Código PHP:
<?php
$ruta=$_SESSION['pob1'];
// Conexión a la base de datos
$bd_host = "localhost";
$bd_usuario = "root";
$bd_password = "";
$bd_base = "asesoria";
$con = mysql_connect($bd_host, $bd_usuario, $bd_password);
if(!$con){
echo "Error al conectar a la Base de Datos.";
}
mysql_select_db($bd_base, $con) or die("No pudo seleccionarse la Base de Datos.");
?>
<?php
$sql = "SELECT * FROM sociedades WHERE id_soci=".$ruta;
$rs = mysql_query($sql, $con) or die("Error al consultar datos personales: ".mysql_error());
while($row = mysql_fetch_assoc($rs))
{
$id_soci=$row["id_soci"];
$nombre=$row["nombre"];
$cif=$row["cif"];
$domicilio=$row["domicilio"];
$cp=$row["cp"];
$ciudad=$row["ciudad"];
$telefono=$row["telefono"];
}
mysql_close($con);
?>
<html>
<head>
<title>Consultar datos personales</title>
<link rel="stylesheet" href="../../bodega.css" type="text/css">
<script language="JavaScript" src="../../bodega.js"></script>
</head>
<body bgcolor="#dddddd" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" >
<div class="centrada" id="capaDatPer" name="capaDatPer" align="center">
<table align="center" cellspacing="2" cellpadding="2" border="6">
<tr>
<td rowspan="16" width="4" height="200%">
<img border="15" src="../../imagenes/copita.jpg" id="imagenDatPer" name="imagenDatPer" width="150" height="70%">
</td>
<td colspan="2">
<b>En esta sección podrá consultar sus datos personales</b><br>
</td>
</tr>
<tr>
<td>
Id_soci:
</td>
<td>
<?php echo $id_soci ?>
</td>
</tr>
<tr>
<td>
Nombre:
</td>
<td>
<?php echo $nombre ?>
</td>
</tr>
<tr>
<td>
Cif:
</td>
<td>
<?php echo $cif ?>
</td>
</tr>
<tr>
<td>
Domicilio:
</td>
<td>
<?php echo $domicilio ?>
</td>
</tr>
<tr>
<td>
CP:
</td>
<td>
<?php echo $cp ?>
</td>
</tr>
<tr>
<td>
Ciudad:
</td>
<td>
<?php echo $ciudad ?>
</td>
</tr>
<tr>
<td>
Telefono:
</td>
<td>
<?php echo $telefono ?>
</td>
</tr>
</table>
</div>
<br>
<center><a href="javascript:close()">Cerrar ventana</a>
</body>
</html>