dajesterofdeath Posted February 10, 2012 Share Posted February 10, 2012 Hi Guys, I have this as a dropdown list. It gets the values from a table. <?php print "<select name=\"newcompany\">\n"; while ($rowb = mysql_fetch_assoc($resulta)){ $id = $rowb['id']; $companya = $rowb['company']; print "<option value=$companya>$companya\n"; }print "</select>\n";?> What i need to do is set its default option to be that of the account i am querying eg. customer details Homer Simpson 742 Evergreen Terrace Springfield PowerPlant The table for companies might beKwikemartPowerPlantSchool When i display the account i want the dropdown to default to the value in sql for that person. Cheers Link to comment Share on other sites More sharing options...
justsomeguy Posted February 10, 2012 Share Posted February 10, 2012 Check if the ID of the row is the same as the one that you're processing, and use the selected attribute on the option to make that one selected. You also need to add a closing option tag. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.