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
Form with multiple db lookups
Moderator: General Moderators
Re: Form with multiple db lookups
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
}
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
Worked a treat. Thanks. Reload isn't that much of a big deal.