As i understand PHP process from top to bottom that order. hence you have to define a variable before the statement using it.
But how would i make a select option value defined as a variable in my main body available for my statement above when the select value changes below should also change the scope automatically?
example.
<?php
// connect to MySQL
$conn1 = dbConnect('admin');
// prepare the SQL query
$sql = "SELECT * FROM contract WHERE cont_num = '$contract_number'";
// submit the query and capture the result
$micko = $conn1->query($sql) or die(mysqli_error());
?>
my html, the variable contract_number is defined as a variable of the select options in the table below. how can i pass it back to the top for my sql statement. i also want the table to reload automatically when the select value changes as the variable value changes so it returns correct info. or if you have a better way i can do this please help.
<table>
<?php
while ($ayanda = $micko->fetch_assoc()) {
?>
<tr>
<select name = "contract_no">
<!--these select options are derived from a different sql statement as the rest of the table-->
<?php
while ($row = $chuchu->fetch_assoc()) {
?>
<option><?php echo $row['cont_num']; ?></option>
<?php $contract_number = '<option value="'.$row.'">'.$value.'</option>';?>
<?php } ?>
</select>
<td></td>
<td><strong>Contruct Customer:</strong></td>
<td><?php echo $ayanda['cont_custm']; ?></td>
</tr>
<tr>
<td><strong>Account Number:</strong></td>
<td><?php echo $ayanda['accnt_num']; ?></td>
<td></td>
<td><strong>Contruct Volume:</strong></td>
<td><?php echo $ayanda['cont_vol']; ?></td>
</tr>
<tr>
<td><strong>Created:</strong></td>
<td><?php echo $ayanda['created']; ?></td>
<td></td>
<td><strong>Broker:</strong></td>
<td><?php echo $ayanda['broker']; ?></td>
</tr>
<?php } ?>
</table>