RE: show list of values and new values

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

 



Create a table (items) with selectable items with these columns

select_id 	| selection | description
------------+-----------+------------
1		| #000000	| White
1		| #FFFFFF	| Black
2		| other	| Another type
2		| second	| Second Type


use "select * from items where select_id='1';
into a variable, say $colors

then
<?php
echo "<select name=color>";
foreach($colors as $color) {
  $selection = $color['selection'];
  $description = $color['description'];
    echo "<option value=\"$selection\">$description</option>";
}
echo "</select>";

/* That will build a dropdown with the available colors (select_id='1')
*/
<form>
Then build an <input type=text> 3 times to do an add to the db, with
select_id,selection, and description. That will add a row to the table, and
each time you run the script above, it will be populated with all the rows
that have select_id='1'. You can use the same table with different
select_id's for different dropdowns.



Gary Every
Sr. UNIX Administrator
Ingram Entertainment
(615) 287-4876
"Pay It Forward"
mailto:gary.every@ingramentertainment.com
http://accessingram.com


> -----Original Message-----
> From: Hull, Douglas D [mailto:ddhull@ku.edu]
> Sent: Wednesday, October 01, 2003 2:52 PM
> To: Note To php mysql List (E-mail)
> Subject:  show list of values and new values
> 
> 
> Just for example, in php how can I show a list of colors so 
> the user can
> select one?  Also if needed the user could add a new color.  
> This could be a
> drop down or whatever.
> 
> How can I make this dynamic so when the user adds the new color that
> anywhere I show the list of colors in my web pages the new 
> color would be
> available for selection for this user and all users following?
> 
> Kind of confusing, let me know if you need more detail.
> 
> Thanks,
> Doug.  
> 
> -- 
> 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