...

View Full Version : PHP Help with Drop Down Menu



winnard2008
07-16-2008, 04:32 PM
Hi

I am fairly new to PHP and am having trouble with one issue.


Basically I have a drop down menu with 3 categories which are setup in a table call

portfolio_cat:

the categories have an ID of 1,2 and 3. There will be no more going into this table.

Basically our old programmer created the other part of this form and I am adding this category drop down to it.

His table called portfolio had the following in it

id
jobtitle
customer
location
info
testimonial
image1
image2
image3

What I need to do is set up the form so that when the client is creating the portfolio they can select which category that information is based on.

Ie portfolio on windows

All the info in the portfolio table will be linked to the portfolio_cat table ID 1.


How do i do this??


Any help would be great.


Danny
NEWBIE PROGRAMMER

Fumigator
07-16-2008, 05:30 PM
My first instinct is to add a column portfolio_cat to your portfolio table.

winnard2008
07-16-2008, 05:41 PM
Hi


I initially thought that. But my boss said I needed to have the categories in a different table with the ID and the category.

There will only ever be 3 categories. Doors, Conservatories and Windows.


The client would select which category the portfolio was going under.

IE they have done a job installing windows, they would select windows in the drop down, then fill in the relevant details.

If i added a category row in the portfolio table, what would be the php code in the form be to recognise which category was selected?

The php script for this page done by the previous programmer is huge, but if you need me to post it to help you more i will.


Cheers

Fumigator
07-16-2008, 07:04 PM
No I don't need the code... the value from a form comes across via the $_POST or $_GET arrays, including the value from a form's <select> element. If this is an unfamiliar concept to you, run through some tutorials and read the PHP manual on how forms are processed.

http://us.php.net/manual/en/tutorial.forms.php

winnard2008
07-16-2008, 08:10 PM
Hi


I think I am getting grips with the $_POST[] thing.

So if I add a row in the portfolio table called categories

inside that there will be

windows
doors
conservatories

Then in the form i would put the value as "windows" "doors" "conservatories"


Then in the PHP i would have



$windows = $_POST['windows'];


While the other part of the form is inserting into the database.
Would I do a query to SELECT the value from the categories row???


Any help on the query section or this part would be great. I am reading through a book at the moment, and am not yet up to this part, or should I say the examples in the book do not cover drop down menus which leaves me in a pickle.


If anybody could help with the building blocks I feel I would find it easier to learn and understand.



Cheers


Dan



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum