Hi, I have this so that the select drop down menu gives the option/value of the "status" so it is selected in the drop down menu, so if the status was "Processing" then the first option shown in the <select> would be "Processing" instead of the pre-defined first option "Pending". Although, I am not sure why this is not giving the correct output, as it still stays at "Pending"...
Does anyone know how I can resolve this?
<?php
$status = "SELECT status FROM orders WHERE id = $id";
$orderstat = mysql_query ($status);
while ($get_info = mysql_fetch_row($orderstat)){
foreach ($get_info as $orderstatus)
print "$orderstatus";
}
$options = array ("Pending", "Processing", "Completed", "Dispatched", "Not Cleared", "Cancelled");
$status = mysql_query ("SELECT status FROM orders WHERE id = ". $id);
$get_info = mysql_fetch_row($orderstat);
$orderstatus = $get_info[0];
$form = '<select name="status">'."\n";
foreach ( $options as $option ) {
$selected = ( $orderstatus == $option ) ? ' selected="selected"' : '';
$form .= '<option value="'. $option .'"'. $selected .'>'. $option .'</option>'."\n";
}
$form .= '</select>';
print $form;
?>
Many thanks in advance...