nashsaint Posted May 13, 2008 Share Posted May 13, 2008 Hi, I used a pulldown menu on my site, it's working and updating the selected item to sql but only the first word and not the 2nd words. So whatever the user chooses, all entry only displays 'Sample' instead of 'Sample one... two... etc..' Any solution? Thanks. <td><?php $cbtype = array( 1=> 'Sample one', 2=> 'Sample two', 3=> 'Sample three', 4=> 'Sample Four', ); $cbtype = str_replace("", "",$cbtype); echo '<select name=cbtype>'; foreach ($cbtype as $key => $value) { echo '<option value='.$value.'>'.$value.''; } echo '</select>'; ?> </td> Quote Link to comment https://forums.phpfreaks.com/topic/105496-pull-down-menu-doesnt-show-2nd-word/ Share on other sites More sharing options...
radar Posted May 13, 2008 Share Posted May 13, 2008 give me a moment i'll get this working for you. Quote Link to comment https://forums.phpfreaks.com/topic/105496-pull-down-menu-doesnt-show-2nd-word/#findComment-540333 Share on other sites More sharing options...
wildteen88 Posted May 13, 2008 Share Posted May 13, 2008 HTML Attribute values should always be wrapped in quotes: echo '<option value="'.$value.'">'.$value . '</option>'; Quote Link to comment https://forums.phpfreaks.com/topic/105496-pull-down-menu-doesnt-show-2nd-word/#findComment-540338 Share on other sites More sharing options...
radar Posted May 13, 2008 Share Posted May 13, 2008 Your code worked fine for me.. as does this code.. <?php $cbtype = array( 1=> 'Sample one', 2=> 'Sample two', 3=> 'Sample three', 4=> 'Sample Four', ); $cnt = sizeof($cbtype); echo '<select name=cbtype>'; for($i=1; $i < $cnt + 1; $i++) { echo '<option value="'$cbtype[$i]'">'.$cbtype[$i].''; } echo '</select>'; ?> try that it worked for me... but so did your code.. Quote Link to comment https://forums.phpfreaks.com/topic/105496-pull-down-menu-doesnt-show-2nd-word/#findComment-540346 Share on other sites More sharing options...
runnerjp Posted May 13, 2008 Share Posted May 13, 2008 humm i also tired it and also it worked for me :S Quote Link to comment https://forums.phpfreaks.com/topic/105496-pull-down-menu-doesnt-show-2nd-word/#findComment-540353 Share on other sites More sharing options...
wildteen88 Posted May 13, 2008 Share Posted May 13, 2008 humm i also tired it and also it worked for me :S read my post here: HTML Attribute values should always be wrapped in quotes: echo '<option value="'.$value.'">'.$value . '</option>'; Quote Link to comment https://forums.phpfreaks.com/topic/105496-pull-down-menu-doesnt-show-2nd-word/#findComment-540354 Share on other sites More sharing options...
nashsaint Posted May 13, 2008 Author Share Posted May 13, 2008 Thanks wildteen88.. That works perfect. Quote Link to comment https://forums.phpfreaks.com/topic/105496-pull-down-menu-doesnt-show-2nd-word/#findComment-540373 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.