I am not sure the title is explained perfectly.
I have 2 select tags and both select tags data are coming from the same table, in
The fist select tag - I am fetching data from the database which stores location name => This works perfectly and I have 3 locations name in the database.
<select name="location" class="form-label" id="location" required>
<option value="">Select Dojo Location</option>
<?php foreach ($location as $row): ?>
<option value="<?php echo $row->id; ?>"><?php echo $row->location; ?></option>
<?php endforeach; ?>
</select>
Image for first select tag
The second select tag - I am fetching prices from different columns of the same table but it shows every price from different locations.
<select name="month" class="form-label" id="month" required>
<option value="">Select Fees Period</option>
<?php foreach ($location as $row1): ?>
<option value="<?php echo $row1->admission_fee_1; ?>">Monthly</option>
<option value="<?php echo $row1->admission_fee_1; ?>">Quarterly</option>
<option value="<?php echo $row1->admission_fee_6; ?>">Half Yearly</option>
<option value="<?php echo $row1->admission_fee_12; ?>">Annually</option>
<?php endforeach; ?>
<?php endif; ?>
Image for second select tag
Image for table data
What I am trying to do is, when user select location in 1 select tag, so it only shows the prices of that selected location from database in second select tag.
This is what I am getting in the result
But I do not succeed yet, any solution is helpful or is there any other way to do this or am I doing it wrong.
Thanks in advance.