I have a form where a user selects some info it is then updated to the database. I have it working so that when the user goes back to that form their info is already highlighted, what I am trying to do is make the process more efficient can anyone help?
this is what I have working...
\n";
if ($status == 1){
echo "
<input type='radio' name='status' value='1' checked>Separated
<br><input type='radio' name='status' value='2'>Divorced
<br><input type='radio' name='status' value='3'>Never Married
<br><input type='radio' name='status' value='4'>Widow / Widower</input> \n";}
else if ($status == 2){
echo "
<input type='radio' name='status' value='1'>Separated
<br><input type='radio' name='status' value='2' checked>Divorced
<br><input type='radio' name='status' value='3'>Never Married
<br><input type='radio' name='status' value='4'>Widow / Widower</input> \n";}
else if ($status == 3){
echo "
<input type='radio' name='status' value='1'>Separated
<br><input type='radio' name='status' value='2'>Divorced
<br><input type='radio' name='status' value='3' checked>Never Married
<br><input type='radio' name='status' value='4'>Widow / Widower</input> \n";}
else if ($status == 4){
echo "
<input type='radio' name='status' value='1'>Separated
<br><input type='radio' name='status' value='2'>Divorced
<br><input type='radio' name='status' value='3'>Never Married
<br><input type='radio' name='status' value='4' checked>Widow / Widower</input> \n";}
else {
echo "
<input type='radio' name='status' value='1'>Separated
<br><input type='radio' name='status' value='2'>Divorced
<br><input type='radio' name='status' value='3'>Never Married
<br><input type='radio' name='status' value='4'>Widow / Widower</input> \n";}
echo "
I've tried to put it into an arry but not able to get it to work
$edu_arr = array (
1 => 'Select One',
2 => 'Some High school',
3 => 'High school/GED',
4 => 'Some college',
5 => 'Associates',
6 => 'Bachelors',
7 => 'Masters',
8 => 'PhD / Post Doctoral'
);
echo " <select name='education' size='1' id='st_age' class='selectOne'>";
foreach ($edu_arr as $key => $value)
{
echo '<option value="'.$key.'"'.(($key == $education) ? ' selected="selected"' : '').'>'.$value.'</option>'; }
}
echo "</select>";
I am fairly new to PHP and haven't really worked with arrays, will an array be faster or is my working code sufficient??