Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/04/2015, 22:43
Avatar de cortess_13
cortess_13
 
Fecha de Ingreso: abril-2015
Ubicación: Tijuana
Mensajes: 14
Antigüedad: 9 años
Puntos: 0
Selecionar datos de select option php y guardar a mysql

HOLA QUE TAL AMIGOS DEL FORO DEL WEB
TENGO UNA DUDA DE COMO INSERTAR EN UNA TABLA UN DATO SELECCIONADO EN UN SELECT DE HTML QUE OBTIENE EL DATO DE LA HABITACION EN PHP Y MYSQL
BUENO LO QUE QUIERO ES INSERTAR EN LA BASE DE DATOS EN LA TABLA RESERVACION LA LLAVER FORANEA DE LA TABLA HABITACION EJEMPLO

EL USUARIO AL REALIZAR UNA RESERVACION ELIGE UNO DE LOS TRES TIPOS DE HABITACIONES
(sus ids)
ID_HABITACION TIPO_HABITACION
1 SENCILLO
2 DOBLE
3 VIP

y al momento nadamas de elegir el tipo de habitacion este le pase ese valor a la tabla
reservacion al aguardar los datos como
RESERVACION
----------------------
id_reservacion
hora_entrada
hora_salida
id_cliente
id_habitacion (llave foranea de tabla habitacion)


hasta ahorita es lo que tengo en php para traer los datos del tipo de habitacion y mostrarlos en el select de html pero no se como aguardar esa eleccion ya me ise volas
espero sus respuestas.


Código PHP:
<?php

  
require_once 'conexion.php';
  
$result "";
  
$conn dbConnect();
  
$row

  
// Create the query
  
$sql 'SELECT hab_id, hab_tipo,hab_costo  FROM habitacion';
  
// we have to tell the PDO that we are going to send values to the query
  
$stmt $conn->query($sql);
  
// Extract the values from $stmt
  
$rows $stmt->fetchAll();
  if (empty(
$rows)) {
    
$result "No se encontraron resultados !!";
  }
 
?>


<select name="tipocuarto"> <option value="00">-- Seleccione --</option>
                  <?php foreach ($rows as $row) {
                    
              echo 
'<option value="'.$row['hab_id'].$row['hab_costo'].'">'.$row['hab_tipo'].'</option>';
            }
?>

                </select></td>