PHP combo box

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
callsreenu
Forum Newbie
Posts: 6
Joined: Sun Nov 23, 2008 11:03 pm

PHP combo box

Post by callsreenu »

Hi ,

any one please give reply for this question..

Urgent pls...


I taken values from database , i can able to display the values on the browser, now i want to put those values inside the combo box. MY CODE IS

$str = array(); foreach($this->advertiserinfo as $adname)
$str = $str.$this->escape($adname->advertiser_name).'<br />';

//echo $this->formSelect('adver_tiser', null, null, $str);( i want to display DB values inside the combo box )

echo $str;

How can i put the those values inside the combo box?
How to move selected values of one combo box to another combo box using >> button in php?


Thanks,
Sreenu.G
sparrrow
Forum Commoner
Posts: 81
Joined: Mon Oct 20, 2008 12:22 pm

Re: PHP combo box

Post by sparrrow »

Seems like you are dragging another programming language into your php code. If you are using foreach as a loop, I would have expected to see the code to repeat surrounded by curly brackets. {} And I'm having trouble following how your array or value is generated, but if $str represents each value you want in a dropdown, you need to print out the code for an html select box and echo the php value in as each option value.

Code: Select all

<select name="name">
<?php
foreach (blah blah) {
print ("<option value=\"$str\">$str</option>");
}
?>
</select>
I don't understand your second question about moving the values with a button.
callsreenu
Forum Newbie
Posts: 6
Joined: Sun Nov 23, 2008 11:03 pm

Re: PHP combo box

Post by callsreenu »

sparrrow wrote:Seems like you are dragging another programming language into your php code. If you are using foreach as a loop, I would have expected to see the code to repeat surrounded by curly brackets. {} And I'm having trouble following how your array or value is generated, but if $str represents each value you want in a dropdown, you need to print out the code for an html select box and echo the php value in as each option value.

Code: Select all

<select name="name">
<?php
foreach (blah blah) {
print ("<option value=\"$str\">$str</option>");
}
?>
</select>
I don't understand your second question about moving the values with a button.
callsreenu
Forum Newbie
Posts: 6
Joined: Sun Nov 23, 2008 11:03 pm

Re: PHP combo box

Post by callsreenu »

Thank u , i got the answer....................
Post Reply