Jump to content

Pull down menu doesn't show 2nd word


nashsaint

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/105496-pull-down-menu-doesnt-show-2nd-word/
Share on other sites

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..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.