Page 1 of 1

Form with multiple db lookups

Posted: Sun Aug 22, 2010 9:59 pm
by shags_j
HI All,

Fairly new to PHP but am having a slight problem with a page. I have a form that has two <select> boxes. The values to be put into the boxes are stored in a database. The tables used are a many to many relationship.

I wanted the values in the second box to reflect the selection from the first box based on the join table for the m-m relationship. (Does this all make sense???).

I am fairly sure that javascript will be involved here but was hoping to avoid it (never learnt javascript). Can I just do this with PHP?

Cheers,

Shags

Re: Form with multiple db lookups

Posted: Sun Aug 22, 2010 10:12 pm
by yacahuma
you can do it. It just you need to refresh the page to do it the code will be something like. This is far from working code. is just the basic idea


if (isset($_GET['sel1'])
{
//show sel2 based on sel1 value
$sql = 'SELECT * FROM TABLE WHERE data=$_GET['sel1']";

//create sel2 options with SQL

//display sel1

//display sel 2
}
else
{
//DISPLAY SEL 1
}

Re: Form with multiple db lookups

Posted: Mon Aug 23, 2010 7:10 pm
by shags_j
Worked a treat. Thanks. Reload isn't that much of a big deal.