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 = "";
				    
			    for($x=0;$x<pg_num_rows($exec);$x++){
					$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:

</div>
        <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>
			</table>
            </strong>

what should i put on ???? parts ?

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

//EDIT

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.

try this out:

<?php
$sql="SELECT * FROM some_table"; 
$result=mysql_query($sql); 

$options=""; 

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

Thanks a lot my friend

You bet.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.