This is a dropdown list of professions of indians... Obviously they are different from professions in other countries at least in the names used...
<tr>
<td>Father's Occupation</td>
<td>
<select name="dropdown1">
<option value="Null" selected>Select an Occupation</option>
<option value="Business Person/Trader">Business Person/Trader</option>
<option value="Chartered Accountant">Chartered Accountant</option>
<option value="School/College/University Teacher">School/College/University Teacher</option>
<option value="Self-Employed">Self-Employed</option>
<option value="Doctor">Doctor</option>
<option value="Engineer">Engineer</option>
<option value="Farmer">Farmer</option>
<option value="Bank Employee">Bank Employee</option>
<option value="Government Service">Government Service</option>
<option value="House Wife">House Wife</option>
<option value="Journalist">Journalist</option>
<option value="Labour">Labour</option>
<option value="Lawyer">Lawyer</option>
<option value="Artist/Media/Entertainment">Artist/Media /Entertainment</option>
<option value="Police">Police</option>
<option value="Private Service">Private Service</option>
<option value="Retired">Retired</option>
<option value="Army/Navy/Airforce">Army/Navy/Airforce</option>
<option value="Official">Official</option>
<option value="Unemployed">Unemployed</option>
<option value="Others">Others</option>
</select>
</td>
</tr>
<td>Father's Occupation</td>
<td>
<select name="dropdown1">
<option value="Null" selected>Select an Occupation</option>
<option value="Business Person/Trader">Business Person/Trader</option>
<option value="Chartered Accountant">Chartered Accountant</option>
<option value="School/College/University Teacher">School/College/University Teacher</option>
<option value="Self-Employed">Self-Employed</option>
<option value="Doctor">Doctor</option>
<option value="Engineer">Engineer</option>
<option value="Farmer">Farmer</option>
<option value="Bank Employee">Bank Employee</option>
<option value="Government Service">Government Service</option>
<option value="House Wife">House Wife</option>
<option value="Journalist">Journalist</option>
<option value="Labour">Labour</option>
<option value="Lawyer">Lawyer</option>
<option value="Artist/Media/Entertainment">Artist/Media /Entertainment</option>
<option value="Police">Police</option>
<option value="Private Service">Private Service</option>
<option value="Retired">Retired</option>
<option value="Army/Navy/Airforce">Army/Navy/Airforce</option>
<option value="Official">Official</option>
<option value="Unemployed">Unemployed</option>
<option value="Others">Others</option>
</select>
</td>
</tr>
Most of the time we need to select one option based on the option posted in the database already. So this code will be useful:
<?php $occupation=array('Select','Business Person-Trader','Chartered Accountant','School-College-University Teacher','Self-Employed','Doctor',
'Engineer','Farmer','Bank Employee','Government Service','House Wife','Journalist','Labour','Lawyer','Artist-Media-Entertainment',
'Police','Private Service','Retired','Army-Navy-Airforce','Official','Unemployed','Others','Reporter');
$year=array('1990','1991','1992','1993','1994','1995','1996','1997','1998',
'1999','2000','2001','2002','2003','2004','2005','2006',
'2007','2008','2009','2010','2011','2012','2013','2014','2015','2016','2017',
'2018','2019');
$relation=array('Aunty/Uncle','PG Tenant','Close Relative','Family Friend','Others');
?>
followed by for fathers occupation:(where $row2[6] is fetched from the database)
<label for="focc">Father's Occupation</label>
<select name="focc" id="focc" value='<?php echo $row2[6];?>'>
<?php
for($i=0;$i<count($occupation);$i++)
{
if($occupation[$i]==$row2[6]) $sel="selected"; else $sel=" ";
echo "<option value='".$occupation[$i]."' ".$sel.">".$occupation[$i]."</option>";
}
?>
</select>
<?php $occupation=array('Select','Business Person-Trader','Chartered Accountant','School-College-University Teacher','Self-Employed','Doctor',
'Engineer','Farmer','Bank Employee','Government Service','House Wife','Journalist','Labour','Lawyer','Artist-Media-Entertainment',
'Police','Private Service','Retired','Army-Navy-Airforce','Official','Unemployed','Others','Reporter');
$year=array('1990','1991','1992','1993','1994','1995','1996','1997','1998',
'1999','2000','2001','2002','2003','2004','2005','2006',
'2007','2008','2009','2010','2011','2012','2013','2014','2015','2016','2017',
'2018','2019');
$relation=array('Aunty/Uncle','PG Tenant','Close Relative','Family Friend','Others');
?>
followed by for fathers occupation:(where $row2[6] is fetched from the database)
<label for="focc">Father's Occupation</label>
<select name="focc" id="focc" value='<?php echo $row2[6];?>'>
<?php
for($i=0;$i<count($occupation);$i++)
{
if($occupation[$i]==$row2[6]) $sel="selected"; else $sel=" ";
echo "<option value='".$occupation[$i]."' ".$sel.">".$occupation[$i]."</option>";
}
?>
</select>
No comments:
Post a Comment