-1
我有一個選擇標籤有一些選項,並嘗試運行基於選定選項的查詢。PHP處理HTML選擇和選項
我的book.php包含帶選項的select標籤,course.php將檢查選中的選項並執行相應的查詢。
我面臨的問題是,當我運行它時,course.php不執行配對操作並引發錯誤。我想知道哪裏出了問題,以及邏輯是否正確。
book.php中:
<div class="input-wrapper">
<?php require "course.php" ?>
<select id="workshop" name="workshop" onchange="return test();">
<option value="">Please select a Workshop</option>
<option value="Forex">Forex</option>
<option value="BinaryOptions">Binary Options</option>
</select>
<select id="Forex" name="Forex" style="display: none">
<option value="">Please select a date</option>
<option value="01/01/01">01/01/01 at 6.30pm</option>
<option value="02/02/02">01/01/01 at 6.30pm</option>
<option value="03/03/03">01/01/01 at 6.30pm</option>
</select>
<select id="Binary" name="Binary" style="display: none">
<option value="">Please select a date</option>
<option value="01/01/01">01/01/01 at 6.30pm</option>
</select>
</div>
course.php:
$form = Array();
$form['workshop'] = $_POST['workshop'];
$form['forex'] = $_POST['Forex'];
$form['binary'] = $_POST['Binary'];
//Retrieve Binary Workshops
if($form['workshop'] == 'Forex'){
$sql = "SELECT id, course, location FROM courses WHERE course LIKE '%Binary%' OR course LIKE '%binary%'";
$query = mysqli_query($link, $sql);
while($result = mysqli_fetch_assoc($query)){
print_r($result);echo '</br>';
}
}else{
$sql2 = "SELECT id, course, location FROM courses WHERE course LIKE '%Forex%' OR course LIKE '&forex%'";
$query2 = mysqli_query($link, $sql2);
while($result2 = mysqli_fetch_assoc($query2)){
print_r($result2);echo '</br>';
}
}
錯誤:通知:未定義指數:車間在C:\ XAMPP \ htdocs中\華保\ course.php第11行
注意:未定義指數:外匯在C:\ XAMPP \ htdocs中\華保\ course.php上線12
*「拋出一個錯誤」 *這是驚人的。 – AbraCadaver
對不起忘記 – Tomazi
你不能訪問數組值直到它們存在。 –