The first dropdown should select all the semester data, and it works. For the second dropdown, it is supposed to select all the student_prg data but it doesn't work (dropdown list empty).
Is there any method to make it work? Please let me if there is any other way to make both the dropdown work.
config.php
<?php
define('DBINFO','mysql:host=localhost;dbname=marketing_system');
define('DBUSER','root');
define('DBPASS','');
$conn = mysqli_connect("localhost","root","","marketing_system");
?>
testreport.php
<div class="modal-body">
<div class="form-group">
<label for="title">Select Semester:</label>
<select name="semester" class="form-control">
<option value="">--- Select Semester ---</option>
<?php
require('../setting/config.php');
$query = "SELECT DISTINCT semester FROM marketing_data ORDER BY semester DESC";
$do = mysqli_query($conn, $query);
while($row = mysqli_fetch_array($do)){
echo '<option value="'.$row['student_matric'].'">'.$row['semester'].'</option>';
}
?>
</select>
</div>
<div class="form-group">
<label for="title">Select Programme:</label>
<select name="prg" class="form-control">
<option value="">--- Select Programme ---</option>
<?php
require('../setting/config.php');
$query2 = "SELECT DISTINCT student_prg FROM marketing_data ORDER BY student_prg DESC";
$do = mysqli_query($conn, $query2);
var_dump($do); die();
while($row = mysqli_fetch_array($do)){
echo '<option value="'.$row['student_matric'].'">'.$row['student_prg'].'</option>';
}
?>
</select>
</div>
Database
mysql> describe marketing_data;
+---------------+------------------+------+-----+---------+--------------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+------------------+------+-----+---------+--------------------+
| student_matric| varchar(10) unsigned | NO | PRI | NULL | auto_increment |
| student_prg | text unsigned | YES | | NULL | |
| semester | varchar(10) | YES | | NULL | |
| intake_year | int(10) | YES | | NULL | |
| student_city | text | YES | | NULL | |
| city_lat | varchar(20) | YES | | NULL | |
| city_long | varchar(20) | YES | | NULL | |
| student_state | text | YES | | NULL | |
| state_code | varchar(100) | YES | | NULL | |
+---------------+------------------+------+-----+---------+--------------------+