bev Posted October 23, 2008 Share Posted October 23, 2008 I have a membership script that I am working on.Once a person registers all of their information shows up in the Admin panel. What shows in Admin is the same registration page just like it looked all filled out before the submit button is clicked. The registration page has a couple drop down select fields on it now that work properly and show the selection in the admin area. Example .... <select name="country" class="select1"> <option value="0" selected>Select</option> <option value="US"<? if($_POST[country]=="US") echo "selected";?>>US</option> <option value="CANADA"<? if($_POST[country]=="CANADA") echo "selected";?>>CANADA</option> </select> Now I added a few fields below that and I need them to post to the admin area as well but I am not sure how the code should look to make it properly work. This is what I currently have... <select name="clientmembership" > <OPTION SELECTED="Client Membership"> ---> Make Selection <---</option> <option value="3 Months $6.50">3 Months $6.50</option> <option value="6 Months $12.00">6 Months $12.00</option> <option value="1 Year $20.00">1 Year $20.00</option> </select> I tried using this <? $sel=mysql_query("select * from sitemembership");?> <select name="sitemembership" class="select1" > <OPTION ="Site Membership"> ---> Make Selection <---</option> <option value="Site Membership $4.95">Site Membership $4.95</option> <? while($fet=mysql_fetch_object($sel)) {?> <option value="<?=$fet-id?>"<? if($_POST[sitemembership]==$fet->id) echo "selected";?>><?=$fet->name?></option> <? }?> </select> That caused the entire registration to not show up in the admin so I am at a loss.. New to PHP and overwhelmed a bit. That code Link to comment https://forums.phpfreaks.com/topic/129813-selects-not-showing-up/ Share on other sites More sharing options...
Alt_F4 Posted October 24, 2008 Share Posted October 24, 2008 Hi, I think you just need to modify your php code that is outputing the data. Try this: (i have spaced it out so it is easier to read) <? $sel=mysql_query("select * from sitemembership"); ?> <select name="sitemembership" class="select1" > <OPTION value="Site Membership"> ---> Make Selection <---</option> <option value="Site Membership $4.95">Site Membership $4.95</option> <? while($fet=mysql_fetch_array($sel)) { ?> <option value="<? echo $fet['id']; ?>" <? if($_POST['sitemembership']==$fet['id']) echo "selected"; ?> ><? echo $fet['name']; ?></option> <? }?> </select> however i would write it like this as it is a bit cleaner: <?php $sel=mysql_query("select * from sitemembership"); ?> <select name="sitemembership" class="select1" > <OPTION value="Site Membership"> ---> Make Selection <---</option> <option value="Site Membership $4.95">Site Membership $4.95</option> <? while($fet=mysql_fetch_array($sel)) { echo '<option value="'.$fet['id'].'"'; if($_POST['sitemembership']==$fet['id']) echo "selected"; echo '>'; //closing option tag echo $fet['name'].'</option>'; } ?> </select> give that a try and see how you go Link to comment https://forums.phpfreaks.com/topic/129813-selects-not-showing-up/#findComment-673409 Share on other sites More sharing options...
iversonm Posted October 24, 2008 Share Posted October 24, 2008 hey just for the record, i was yelled at earlier for this so ill just inform you what i was told always always always open php with <?php never use <? Link to comment https://forums.phpfreaks.com/topic/129813-selects-not-showing-up/#findComment-673433 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.