Page 1 of 1

PHP combo box

Posted: Sun Nov 23, 2008 11:15 pm
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

Re: PHP combo box

Posted: Mon Nov 24, 2008 9:53 am
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.

Re: PHP combo box

Posted: Mon Nov 24, 2008 10:44 pm
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.

Re: PHP combo box

Posted: Mon Nov 24, 2008 10:46 pm
by callsreenu
Thank u , i got the answer....................