Combobox with db field

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
Arsench2000
Forum Commoner
Posts: 38
Joined: Sat Sep 15, 2007 8:18 pm

Combobox with db field

Post by Arsench2000 »

Hello,
how can synchronize the combobox with my p_name field that all p_name data can be avalaible in combobox list?

Im doing select in sql then in the combobox <option> echo"$p_name"; </option> but it didnt select all data from p_name.

any advice please?


Thanks a lot
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Combobox with db field

Post by papa »

SHow us your mysql query and remove the "s from the var name.
Arsench2000
Forum Commoner
Posts: 38
Joined: Sat Sep 15, 2007 8:18 pm

Re: Combobox with db field

Post by Arsench2000 »

thanks for replay.
my sql is a simple sql

Code: Select all

 
$sql=mysql_query("select * from t")
while($r= etc...)
 
$p_name =$r["p_name"];
 
then doing echo in the combobox option.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Combobox with db field

Post by aceconcepts »

You can output your results in a select element:

Code: Select all

 
echo'<select name="mySelect">';
while($row=mysql_fetch_array($query))
{
   echo'<option value="'.$row['value'].'">'.$row['display'].'</option>';
}
echo'</select>';
 
Arsench2000
Forum Commoner
Posts: 38
Joined: Sat Sep 15, 2007 8:18 pm

Re: Combobox with db field

Post by Arsench2000 »

aceconcepts wrote:You can output your results in a select element:

Code: Select all

 
echo'<select name="mySelect">';
while($row=mysql_fetch_array($query))
{
   echo'<option value="'.$row['value'].'">'.$row['display'].'</option>';
}
echo'</select>';
 
Thank you very much, thats working very good, thanks again
Post Reply