I have a database with agencies table, contacts table and phone numbers table.
Each agency can have many contacts and each contacts can have many phone numbers.
I have a dynamic Update form for each agency that lists out all the contacts for that agency and their
phone numbers. When the user performs changes, i need these updated form variables(multidimensional arrays)
that need to be passed on to the processing page to update the database.
here is the code:
$result4 = " SELECT contacts.contact_id, agencies.agency_id, last_name, first_name,
title
FROM agencies, contacts
WHERE agencies.agency_id = contacts . agency_id
AND agencies.agency_id='$agency_id'
ORDER BY last_name";
$qresult4 = mysql_query($result4) or die(mysql_error());
<table>
<?php while($row = mysql_fetch_array($qresult4))
{
?>
<tr>
<td> <? echo $row ["contact_id"]; ?> </td>
<td width="25%" class="content"><input size="25" type="text" name="last_name" value="<? echo $row["last_name"]; ?>"></td>
<td width="25%"><input type="text" size="25" name="first_name" value="<? echo $row["first_name"];?>"></td>
$result5 = "select area_code, phone_number, extension, phone_type
FROM contacts, phone_numbers, phone_number_phone_types,phone_types
WHERE contacts . contact_id = phone_numbers . contact_id
AND phone_numbers.phone_number_id = phone_number_phone_types . phone_number_id
AND phone_types.phone_type_id = phone_number_phone_types . phone_type_id
And contacts.contact_id = '$row[contact_id]' ";
$qresult5 = mysql_query($result5) or die(mysql_error());
while($row1 = mysql_fetch_array($qresult5) )
{
?><td width="5%" bgcolor="#9999ff" class="content"><input size="5" type="text" name="<? echo "$area_code[$i]" ?>" value="<? echo $row1["area_code"]; ?>"></td>
<td width="15%"><input type="text" name="phone_number" size="15" value=" <?php echo $row1["phone_number"]; ?>"> </td>
<td width="5%"><input type="text" name="extension" size="5" value=" <?php echo $row1["extension"] ; ?>"> </td>
<td width="10%"><input type="text" name="phone_type" size="10" value=" <?php echo $row1["phone_type"] ;?>"></td>
</tr><? } }?>
</table>
Here both the contacts as well as their phone numbers are dynamic, deping on the agency selected.
Please can anyone suggest on how I can retrive, store and pass these arrays on to the next page?
Any help is much appreciated.
Thanks
Sunder.