I am new at developing. This is some code I wrote below. I have a dynamic drop down list with 3 selections. The first selection is Country and then provinces and then cities. I used a database for values because of the size of data. I am able to run the below code if I set $coun_val='Canada' and COUNTRY_VAL='Canada'(one of the database values) and see the correct provinces. However I want to use $coun_val=$_REQUEST['Country'] and use that in the sql query as well, however the value seems to be null and nothing populates.
Note: $_REQUEST['Country'] is used in the first select in an if statement to set the selected value and works.
<div class="fieldsarea"><select id="select_province" class="searchfields" name="select_province">
<option class="" value="">--Select Province/State--</option>
<?php
$coun_val=$_REQUEST['Country'];
$query1 = "SELECT * FROM dynamicprovs WHERE COUNTRY_VAL=mysqli_real_escape_string($conn,$coun_val);
$result1 = mysqli_query($conn,$query1) or die(mysqli_error($conn));
while ($record = mysqli_fetch_array($result1)) {
$prov_val=$record['PROVINCE_VAL'];
if($_REQUEST['province']==$prov_val){
echo "<option class='" . $coun_val . "'value='" . $prov_val ."'selected='selected'>'". $prov_val ."'</option>";
}else
{
echo "<option class='" . $coun_val . "'value='" . $prov_val ."'>'". $prov_val ."'</option>";
}
}
?>
</select>
</div>