Page 1 of 1
Combobox with db field
Posted: Wed Oct 29, 2008 9:34 am
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
Re: Combobox with db field
Posted: Wed Oct 29, 2008 9:43 am
by papa
SHow us your mysql query and remove the "s from the var name.
Re: Combobox with db field
Posted: Wed Oct 29, 2008 11:10 am
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.
Re: Combobox with db field
Posted: Wed Oct 29, 2008 11:26 am
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>';
Re: Combobox with db field
Posted: Sat Nov 15, 2008 6:55 am
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