RE: [PHP] Simple question I guess.

2002-07-22 Thread John Holmes

 I have a site with all my movies and stuff stored in a database. And I
 have
 made a admin page where I can add, delete and update records. When I
add
 new
 records, I have made a listbox for the category (ex. action, comedy
etc.)
 so
 I dont have to write it every time I add a new record. But when I push
the
 update button and the data thats stored in the database is printed its
 printed just in a textarea. I know its possible to list the data in a
 listbox, but how do I get the right category selected for the movie I
 choose?

select name=whatever
option value=1 ?if($something==1) { echo selected; }
?One/option
option value=2 ?if($something==2) { echo selected; }
?Two/option
etc...
/select

Put it into a function and the possible values into an array to make it
easier...

---John Holmes...



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




Re: [PHP] Simple question I guess.

2002-07-22 Thread Evan Nemerson

Okay im not sure i understand you- you want to create a page where it will 
suck an item out of a database, and use it to choose which item in a drop 
down menu should be selected?

If so, you can try something like

select name=catagory
option value=0?php if ($catagory == 0) {echo  selected}; 
?Action/option
option value=1?php if ($catagory == 1) {echo  selected}; 
?Comedy/option
option value=2?php if ($catagory == 2) {echo  selected}; 
?Etc./option
/select



On Monday 22 July 2002 16:07 pm, Raymond Lilleodegard wrote:
 Hi!

 I have a site with all my movies and stuff stored in a database. And I have
 made a admin page where I can add, delete and update records. When I add
 new records, I have made a listbox for the category (ex. action, comedy
 etc.) so I dont have to write it every time I add a new record. But when I
 push the update button and the data thats stored in the database is printed
 its printed just in a textarea. I know its possible to list the data in a
 listbox, but how do I get the right category selected for the movie I
 choose?

 Best regards Raymond

-- 
What I conclude is that religion has nothing to do with experience or reason 
but with deep and irrational needs

Richard Taylor


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