Hi! I need some help...

i searched a lot.. but dind't found or worked any code.. so i need help please..

i just need a simple thing...

i want to show on a combobox, a list of the things that i have (inserted before on my database-postgreSQL) on a collumn from a table...

i.e. Want a combobox that when i click on it, it show's all my client's name that i have on my database (my database is on postgreSQL).

I have this code to make a combobox on my Base.php :

function Combo($sql, $strValue, $strText) {
			    $exec = pg_query($this->db, $sql);
			    $strHTML = "";
					$dados = pg_fetch_assoc($exec);
					$strHTML = $strHTML ."<option value='" .$dados[$strValue]. "'>" .$dados[$strText]. "</option>\n";
			    return $strHTML;

but i don't know what to set on my page side:

        <form action="criaruser.php" method="post">
            <table width="280" border="1">
                <strong><td>&nbsp;Client Name:</td></strong>
			    <td><select name="[B]???[/B]" style="width:150px;"> 
			    <option value="">[Todos]</option>	
			    <?=$db->Combo([B]????[/B], [B]????[/B], [B]????[/B])?></select></td>

what should i put on ???? parts ?

7 Years
Discussion Span
Last Post by phobia1

You want to populate a dropdown menu with a list of names from your database?


Sorry, wasn't paying attention and seen you are working with a combo box. I can show you how to do it with a drop down.

Edited by CFROG: n/a


try this out:

$sql="SELECT * FROM some_table"; 


while ($row=mysql_fetch_array($result)) { 
$options.="<OPTION VALUE=\"$value\">".$value; 
<select name="enter_name">
<option value=0>Please Choose a value

Edited by CFROG: n/a


1. $query="SELECT DISTINCT * FROM Garant GROUP BY Location";
2. echo "<select name=areasearch value=''>Location</option>";
// printing the list box select command

3. while($nt=mysql_fetch_array($result)){
//Array or records stored in $nt
4. echo "<option value=$nt[Town]>$nt[Location]</option>";
/* Option values are added by looping through the array */
5. }
6. echo "</select>";// Closing of list box

7. echo $areasearch;

8. output_array($areasearch);
9. Function output_array($areasearch){}

Hi, the above code reads a Location value into a listbox (areasearch) what I want is to click on any name in this list and run a search. You can see the actual page at http://areabulgaria.net/search4a.php
Thanks in advance for any help given.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.