你好,我有2个选择以相同的形式:变化与阵列选择值的值
<form role="form" method="post" action="controlreservas/agregareserva.php" >
<!--ID RESIDENCIAL-->
<?php
include "controlreservas/conexion.php";
$sql1= "select id_residencial from residenciales";
$query = $con->query($sql1);
?>
<label>Residencial</label>
<select name="id_residencial">
<?php if($query->num_rows>0):?>
<?php while ($r=$query->fetch_array()):?>
<option value="<?php echo $r["id_residencial"]; ?>"><?php echo $r["id_residencial"]; ?></option>
<?php endwhile;?>
<?php else:?>
<?php endif;?>
</select>
</div>
<!--ID RESIDENCIAL-->
<!--ID HABTIACION (NUMERO HABITACION)-->
<?php
include "controlreservas/conexion.php";
$sql1= "select id_residencial,id_habitacion
from habitaciones
where id_residencial=".$_POST["id_residencial"];
$query = $con->query($sql1);
?>
<label>N° Habitación</label>
<select name="id_habitacion">
<?php if($query->num_rows>0):?>
<?php while ($r=$query->fetch_array()):?>
<option value="<?php echo $r["id_habitacion"]; ?>"><?php echo $r["id_habitacion"]; ?></option>
<?php endwhile;?>
<?php else:?>
<?php endif;?>
</select>
</div>
<!--ID HABTIACION (NUMERO HABITACION)-->
<button type="submit" class="btn btn-default" style="float:left">Ingresar Reserva</button>
</form>
首先选择it's工作,第二个选择,我需要采取什么样的值的形式: where id_residencial=".$_POST["id_residencial"];
,但我不知道这是怎么回事(我看到更改值的代码,但没有与阵列:/)
是'$ _POST [“id_residencial”]'单个id值还是数组? –
我错过了一些东西,你的查询这一个应该产生语法错误'$ sql1 =“select id_residencial,id_habitacion from habitaciones where id_residencial =”。$ _ POST [“id_residencial”];'这是错的,希望我是正确 –