grobermatica
Programmer
I have a form which updates records, some of the field in the update form are combo boxes and the second one is dynamically dependant on the first one. I have another combo box at the top of the form in which you select the record you want to edit. This populates a url variable which is the record ID.
My problem is this, I need the 2 dependant combo boxes to populate correctly when the record is selected.
I would usually use another URL variable but I can't work out how to populate it.
Having previously used MS Access I would normally use a DLookup function and have found a custom PHP function on the web and use the value in the query:
This works but is always a record late... so If I select a record to edit... the value plugged into the query is 0, but the real value may be 1, and then if I choose another record, it uses the 1 from the previous request but the actual value may be 2... hope I've explained that well enough.
I need it all to happen in one go so when I select the record the dependant combo boxes populate with the dependant data.
Any ideas / suggestions would be welcome
Many thanks
Craig
My problem is this, I need the 2 dependant combo boxes to populate correctly when the record is selected.
I would usually use another URL variable but I can't work out how to populate it.
Having previously used MS Access I would normally use a DLookup function and have found a custom PHP function on the web and use the value in the query:
Code:
function DLookup($fld, $tab, $whr)
{
$q = "Select $fld from $tab where $whr";
$rst = mysql_query($q);
if ($row = mysql_fetch_object($rst))
return $row->$fld;
else
return NULL;
}
This works but is always a record late... so If I select a record to edit... the value plugged into the query is 0, but the real value may be 1, and then if I choose another record, it uses the 1 from the previous request but the actual value may be 2... hope I've explained that well enough.
I need it all to happen in one go so when I select the record the dependant combo boxes populate with the dependant data.
Any ideas / suggestions would be welcome
Many thanks
Craig