Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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