Posted by Joe Makowiec on 12/29/05 15:05
On 29 Dec 2005 in alt.php.sql, powerx wrote:
> Would have thought this was a FAQ but I'm having trouble googling it
> so any help appreciated...
>
> I have an SQL database
>
> ID BRAND
> 1 Apples
> 2 Pears
> 3 Oranges
> 4 ...
> 5 ...
>
> What is the easiest way of getting the SQL "Brand List" into a
> dropdown menu in my HTML / PHP page. It should automatically update
> when new items are added?
Pseudocode; adapt to your serverside scripting:
<!-- Create a recordset -->
<$ SELECT ID, BRAND FROM database ORDER BY BRAND $>
....
<select name="myselect">
<!-- Start of repeat region code goes here -->
<option value="<$ print ID $>"><$ print BRAND $></option>
<!-- End of repeat region code goes here -->
</select>
....
--
Joe Makowiec
http://makowiec.org/
Email: http://makowiec.org/contact/?Joe
Navigation:
[Reply to this message]
|