I am trying to to use html select and basing on the selected value display the mysql query value. I pick the selected value by id using javascript and their after convert them to php variables as demostrated below
I then use a comparison statement to evaluate the php variable and if true go ahead echo the db query result. However the if statement on the php script seems not to be working and doesnt return or echo anything
//HTML FORM select
<form method="post" action="" name="myform">
<th style="width:3%;" >MOH
<select name="moh" id="myselect" onchange="javascript: form.submit();">
<option id="4" value="received_moh_day1">Day 1</option>
<option id="5" value= "received_moh_day2">Day 2</option>
<option id="6" value= "received_moh_day1_and_2">Day 1 and 2</option>
</select>
</th>
</form>
<script type="text/javascript">
var jvalue_moh_1 = document.getElementById('4').value;
var jvalue_moh_2 = document.getElementById('5').value;
var jvalue_moh_3 = document.getElementById('6').value;
//document.getElementById('personlist').value=Person_ID;
</script>
<script type="text/javascript">
//Convert Javascript variable to php variable
<?php
$moh1 = "<script>document.write(jvalue_moh_1)</script>";
$moh2 = "<script>document.write(jvalue_moh_2)</script>";
$moh3 = "<script>document.write(jvalue_moh_3)</script>";
//$moh = "<script>document.write(jvalue2)</script>" ;
?>
</script>
</tr>
</thead>
<tbody>
<?php endif; ?>
<?php
$i=1;
if ($data && $_GET['log'] == 'ATTNSC') {
print_r($moe1);
foreach ($data as $key => $value) {
//print_r($moe3);
if($moe3 == 'received_moe_day1_and_2'){
echo "<td class='align-td' id='received_moe_day1_and_2_td".$i."'>".$value['received_moe_day1_and_2']."</td>";
}
elseif ($moe2 == 'received_moe_day2'){
echo "<td class='align-td' id='received_moe_day1_and_2_td".$i."'>".$value['received_moe_day2']."</td>";
}
elseif ($moe1 == 'received_moe_day1'){
echo "<td class='align-td' id='received_moe_day1_td".$i."'>".$value['received_moe_day1']."</td>";
}
elseif ($moh3 == 'received_moh_day1_and_2'){
echo "<td class='align-td' id='received_moh_day1_and_2_td".$i."'>".$value['received_moh_day1_and_2']."</td>";
}
elseif ($moh2 == 'received_moh_day2'){
echo "<td class='align-td' id='received_moh_day1_and_2_td".$i."'>".$value['received_moh_day2']."</td>";
}
elseif ($moh1 == 'received_moh_day1') {
echo "<td class='align-td' id='received_moh_day1_td".$i."'>".$value['received_moh_day1']."</td>";
}
$i++;
}
}else{
?>