RE: Conditional default value of drop-down list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Not exactly. My application is a software catalog,
where an admin can insert new software through a form,
and later on, edit it through a similar form. What I
need is that the dropdown menus in the editing form,
reflect values set for the piece of software.
So my categories table can look something like this:
id          descr
1      Operating Systems
2      Graphics Design
3      Word Processors


And I populate the dropdown list with:
<tr><td>Category:</td>
   <td><select name="category">
<?
$query = "SELECT descr from categorias";
   $result = mysql_query($query, $link);
     if(mysql_num_rows($result)) {

       while($row = mysql_fetch_row($result))
       {
          print("<option
value=\"$row[0]\">$row[0]</option>");
       }
     } else {
       print("<option value=\"\">No categories
available</option>");
     }
?>
  </select><br></td>
</tr>


What I need is that the value that the dropdown menu
shows, is the actual category set for that software.
The admin can then change it, but the initial value
needs to be the correct one.

J

--- "Snijders, Mark" <Mark.Snijders@atosorigin.com>
wrote:
> <select name=example>
> 
> 	<option value='$id'>$name</option>
> 
> or:
> 
> 	option value='$id'>$id - $option</option>
> 
> as you can see:
> 
> the value is what you give back to the $_POST, and
> wat is between
> <option></option> really doesn't matter, it's just
> what you see... so you
> can put anything between it...
> 
> is this what you mean?
> 
> 
> 
> -----Original Message-----
> From: Jason End [mailto:bensnephew@yahoo.com]
> Sent: maandag 7 april 2003 9:27
> To: php-bb
> Subject:  Conditional default value of
> drop-down list
> 
> 
> 
> Is it possible to create a drop-down list where the
> initial value displayed depends on a variable. Say I
> have a table called "categories" with columns "id"
> and
> "descr". Currently I populate the list with a query:
> $query = "SELECT descr from categories";
> 
> How could I make the default value of the list be
> conditional on the categories id? So if the variable
> categories id is "3", the initial value shown in
> that
> drop down menu will be the description of the
> category
> with id 3.
> Does this make sense?
> 
> thanks, 
> 
> J
> 
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - File online, calculators, forms,
> and more
> http://tax.yahoo.com
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux