Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
|
|
PHP pull down menu - any suggestions? |
Page: 1 | Reply |
Feb 16th 2004 | #142421 Report |
Member since: Jun 5th 2003 Posts: 93 |
Ok, so imagine you have a user account, and the account holds the state you reside in. Now you want to edit that user account online, so the PHP makes a database call and loads up all your user info. How on earth can one make the state you are in "selected" from a pull down menu? I really do NOT want to put an [PHP][/PHP] In every "option" tag in the list...seems too tedious. I need to cheat because I am lazy, and lazy people rule! If I indeed do need to put that damn "if" statement infront of every state in the list...I guess thats fine, but I'd rather not. |
Reply with Quote Reply |
Feb 17th 2004 | #142429 Report |
Member since: Nov 26th 2001 Posts: 2586 |
Well if you had the values for the option in an array, eg: [php] $option_array = array('ca','wa'); ...etc. [/php] You could just loop thru with an if statement. [php] $num = count($option_array); for ($i=0;$i<$num$i++) { if ( $option_array[$i] == $user_state ){ print ' |
Reply with Quote Reply |
Feb 17th 2004 | #142452 Report |
Member since: Jun 5th 2003 Posts: 93 |
[php] $state_array = array( 'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming' ); $num = count($state_array); echo ''; [/php] Wow...great call. Thanks a lot! The above codes works well for me, so anyone who has the same issue....feel free to use it! Thanks a lot. |
Reply with Quote Reply |
Page: 1 | Back to top |
Please login or register above to post in this forum |
© Web Media Network Limited. All rights reserved. No part of this website may be reproduced without written permission. Photoshop is a registered trademark of Adobe Inc.. TeamPhotoshop.com is not associated in any way with Adobe, nor is an offical Photoshop website. |