Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: Does any body know if its posible to create a select box on a form- dynamically?


Message #1 by Jorge Cordero <jorge@d...> on Thu, 07 Jun 2001 15:12:35 -0600
Jorge,

I think the query and while statements still need some work. 
Are you trying to read just the rows where the product 
column equals $product? If so then try this:

$result = mysql_query("SELECT prod_num, producto FROM products WHERE
product = '$product'");
while ($qprod = mysql_fetch_row($result)) {
  $productsOptions .= "<option
value=".$qprod['prod_num'].">".$qprod['producto']."</option>";
}

Sheila


LUIS M MORALES wrote:
> 
> Dear Jorge,
> 
> add this to the form...
> 
> <?
>   $productsOptions = "";
>  $qprod=mysql_query("SELECT * FROM products");
>    while($product=$qprod["product"]){
>     $productsOptions .= "<option
> value=".$qprod['prod_num'].">".$qprod['producto']."</option>";
> ?>
> <select name="formProduct">
> <? echo $productsOptions; ?>
> </select>
> 
> and voila!!
> 
> Best regards,
> 
> Luis Morales
> 
> Jorge Cordero wrote:
> 
> > Hi There I have been trying to create a form
> > as follows
> > <td>
> >
> >        <select name="one">
> > <?
> >  $qprod=mysql_query("SELECT * FROM products");
> >    while($product=$qprod["product"]){
> >    $product=$qprod["producto"];
> >    $prod_num=$qprod["prod_num"];
> >    $precio=$qprod["precio"];
> > ?>
> >    <option value="<?echo('$prod_num');?>" selected></option>
> >
> >    <?}?>
> >           </select>
> > </td>
> >     I want to generate this select drop down menu in a form so when i
> > increase or modifiy the database this gets updated automaticaly
> >      I know there is a trick to it can some one tell me
> >
> > Thanks
> >
> > Jorge Cordero
> 

  Return to Index