我只是在整个晚上试图显示您在代码中找到的查询中的项目。该程序应该允许用户选择出发和到达,并且在点击按钮之后,页面刷新消除路线的价格。该程序一直有效,直到最后几行,经过一些测试,我的猜测是查询无法读取这两个变量。你有什么建议吗?提前感谢您的耐心和帮助
代码下方,这是我的测试网站的link。
<form action='index.php' method='post'>
Select Departure:
<select name="partenze" class="form-control">
<option value="">--- Select Departure ---</option>
<?php
require('prova1.php');
$sql1 = "SELECT * FROM partenze";
$sql2 = "SELECT * FROM arrivi";
$result1 = $mysqli->query($sql1);
while($row1 = $result1->fetch_assoc()){
?>
<option value="<?php echo $row1["p_ID"]; ?>"><?php echo $row1["p_localita"]; ?></option>
<?php } ?>
</select>
<br>
Select Arrival:
<select name="arrivi" class="form-control">
<option value="">--- Select Arrival ---</option>
<?php
$result2 = $mysqli->query($sql2);
while($row2 = $result2->fetch_assoc()){
?>
<option value="<?php echo $row2["a_ID"]; ?>"><?php echo $row2["a_localita"]; ?></option>
<?php } ?>
</select>
<input type='submit' name='submit' id='submit' value='Get Selected Values' />
</form>
<?php
if(isset($_POST['submit'])){
$selected_val1 = $_POST['partenze'];
$selected_val2 = $_POST['arrivi'];
require('prova1.php');
$result3 = $mysqli->query("SELECT * FROM listino WHERE partenza = '".$selected_val1."' AND '".$selected_val2."'");
while($row3 = $result3->fetch_assoc()){
echo $row3['prezzo'];
}
}
?>