thara Posted October 30, 2012 Share Posted October 30, 2012 hi.. can anybody tell me what is the wrong with this code....? <?php // array for tution option for searching $findOptions = array( 1 => 'Private Tutors', 'Tutorial Centers', 'Individual Classes', 'Group Classes', 'Online Classes', 'Study Packs'); // Make the find tution option drop down menu echo '<label><select name="search_option">'; foreach ($findOptions as $key => $value) { echo '<option value="'. $key . '"' ; // Check for stickyness: if ( isset( $_POST['search_option']) && $_POST['search_option'] == $value ) echo ' selected="selected"'; echo " >$value</option>\n"; } echo '</select></label>'; ?> I am trying to make this select box to stickness.. but it is not working.. thanks Quote Link to comment https://forums.phpfreaks.com/topic/270083-form-stickyness-not-working/ Share on other sites More sharing options...
Muddy_Funster Posted October 30, 2012 Share Posted October 30, 2012 I'm sorry....your trying to do what? Quote Link to comment https://forums.phpfreaks.com/topic/270083-form-stickyness-not-working/#findComment-1388787 Share on other sites More sharing options...
Beeeeney Posted October 30, 2012 Share Posted October 30, 2012 Make it so that when someone submits the form, it remembers what was submitted so they don't have to enter it again next time. I think. Quote Link to comment https://forums.phpfreaks.com/topic/270083-form-stickyness-not-working/#findComment-1388790 Share on other sites More sharing options...
thara Posted October 30, 2012 Author Share Posted October 30, 2012 beeeeney you are correct... so how can i do it??? Quote Link to comment https://forums.phpfreaks.com/topic/270083-form-stickyness-not-working/#findComment-1388791 Share on other sites More sharing options...
Muddy_Funster Posted October 30, 2012 Share Posted October 30, 2012 ahh, then your checking the wrong thing, you want to check $key, not $value in this line : if ( isset( $_POST['search_option']) && $_POST['search_option'] == $value ) Quote Link to comment https://forums.phpfreaks.com/topic/270083-form-stickyness-not-working/#findComment-1388794 Share on other sites More sharing options...
Jessica Posted October 30, 2012 Share Posted October 30, 2012 echo '<option value="'. $key . '"' ; // Check for stickyness: if ( isset( $_POST['search_option']) && $_POST['search_option'] == $value ) echo ' selected="selected"'; echo " >$value</option>\n"; I would assume that $_POST['search_option'] would match $key, not $value. Quote Link to comment https://forums.phpfreaks.com/topic/270083-form-stickyness-not-working/#findComment-1388795 Share on other sites More sharing options...
Beeeeney Posted October 30, 2012 Share Posted October 30, 2012 (edited) I'm not 100% sure how you'd go about doing it but I'm sure it involves sessions, cookies, writing to a database and then pulling the same information from the database next time, based on the cookie. That's how I'd do it, anyway. Edit: What they said ^ Edited October 30, 2012 by Beeeeney Quote Link to comment https://forums.phpfreaks.com/topic/270083-form-stickyness-not-working/#findComment-1388796 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.