Ver Mensaje Individual
  #4 (permalink)  
Antiguo 24/05/2014, 13:16
lucaa31
 
Fecha de Ingreso: mayo-2014
Mensajes: 13
Antigüedad: 10 años
Puntos: 0
Respuesta: Obtener valores de tabla

Perdón. A la tabla que me refiero es a la que se puede hacer en un formulario. Esta tabla es cargada con datos traidos de una base de datos.
Lo que yo necesito es extraer un dato de la tabla del formulario una vez ya cargada.

<!DOCTYPE html>
<?
session_start();
?>
<html>

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>logout</title>
<style type="text/css">
.auto-style3 {
color: #FF0000;
text-align: left;
}
.auto-style4 {
text-align: right;
}
.auto-style5 {
color: #000000;
}
.auto-style6 {
border: 1px solid #000000;
background-color: #C0C0C0;
}
.auto-style7 {
color: #FF0000;
}
.auto-style8 {
text-decoration: none;
}
</style>



<?
error_reporting(E_ALL ^ E_NOTICE);
?>


<?php
if ($_GET['accion']=="insertar")
{

insertar();
}

?>

<?
function insertar(){
$conexion=mysqli_connect("localhost","root","","pr actico");
if(!$conexion){
echo "no se pudo conectar a la base";
}
else{
echo "Conexion a la base correctamente";
}

/**FALTA PASAR LA VARIABLE DE LA FUNCION JAVASCRIPT A PHP **/
$Guardar=$conexion->query("Insert into reservas(Usuario,Destino) VALUES ('$_SESSION[nombreusuario]','$destino')");
$conexion->close();
}
?>
</head>
<body>
<form method="post" action="cliente.php" name="formulario">

<div class="auto-style4">
<a href="inicial.php" class="auto-style8"><span class="auto-style7">logout</span></a>
</div>
<h4 class='auto-style3'><span class='auto-style5'>Bienvenido/a sr/sra:<?php echo $_SESSION[nombreusuario] ?> </span> </h4>
<fieldset name="Group1" style="width: 535px" >
<legend>Sus datos son</legend>
<br>
Nombre:
<input name="txtnombre" type="text" style="width: 233px" placeholder="escriba su Nombre" /> <br>
<br>
Apellido:
<input name="Text1" type="text" style="width: 229px" placeholder="escriba su apellido" /><br>
<br>
Email:
<input name="email" type="text" style="width: 270px" placeholder="escriba su email" required/><br>
<br>
Teléfono:
<input name="Text1" type="text" style="width: 229px" placeholder="escriba su teléfono" /><br>
<br>
Nro.Pasaporte:
<input name="Text1" type="text" style="width: 176px" placeholder="escriba su N° pasaporte" /><br>

</fieldset>
<br>
<br>
<br>
<table align="center" style="width: 540px; height: 97px" class="auto-style6" border="3" id="tabla"">
<th valign>Destino</th>
<th valign>Costo</th>
<th valign>Fecha</th>
<th valign>Vacante</th>
<th valign>Reservar</th>



<?php

$conexion=mysqli_connect("localhost","root","","pr actico");
if(!$conexion){
echo "no se pudo conectar a la base";
}
else{
echo "Conexion a la base correctamente";
}
$registros=$conexion->query("Select * from destinos");
foreach($registros as $filas){
echo "<tr style='cursor: pointer' >";
echo "<td>$filas[Destino]</td>";
echo "<td>$filas[Costo]</td>";
echo "<td> $filas[Fecha]</td>";
echo "<td>Si</td>";
$reservas=$conexion->query("Select * from reservas where destino='$filas[Destino]' and usuario='$_SESSION[nombreusuario]'");
$recorrer = mysqli_fetch_array($reservas);
$cantidadreservas=$reservas->num_rows;
if($cantidadreservas>=1){
echo" <td>No se puede reservar</td>";
}
else{

echo" <td><a href='".$_SERVER['PHP_SELF']."?accion=insertar&usuario=$_SESSION[nombreusuario]'>Reservar</a> </td>";
}
echo "</tr>";
}
$conexion->close();
?>



</table>




</form>
</body>

</html>