I have a select tag with some options and trying run a query based on a selected option.
My book.php contains the select tag with option and course.php will check the selected option and execute the appropriate query.
The problem I am facing is that course.php does not do what it spouse to and throws an error when i run it. I would like to find out where am going wrong with it and if the logic is correct.
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>';
}
}
error: Notice: Undefined index: workshop in C:\xampp\htdocs\opes\course.php on line 11
Notice: Undefined index: Forex in C:\xampp\htdocs\opes\course.php on line 12