I can create a main_office, suboffice, and display all with no problems. Office and Suboffice share the same table. When I create main_office and modify it, there are no problems. When I create a suboffice and modify it, there are no problems. When I have a main_office and a related suboffice together, I modify the main_office and go back to the display page. The modified main_office shows up with a new unique id, but the original main_office and it's related suboffice are displayed with updated id's and they are the same.
It will be:
main_office_1 id=1
sub_office_1 id = 2
After modifying the main_office_1, it reads something like this:
main_office_1 id=3
sub_office_1 id = 3
main_office_that_was_modified id=1
This is some of the modify page code (ala DW). If you need more details, please let me know:
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "office")) {
$updateSQL = sprintf("UPDATE offices SET main_office=%s, main_office_manager=%s, main_office_manager_email=%s, main_office_poc=%s, main_office_poc_email=%s WHERE id=%s",
GetSQLValueString($_POST['main_office'], "text"),
GetSQLValueString($_POST['main_office_manager'], "text"),
GetSQLValueString($_POST['main_office_manager_email'], "text"),
GetSQLValueString($_POST['main_office_poc'], "text"),
GetSQLValueString($_POST['main_office_poc_email'], "text"),
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_comments, $comments);
$Result1 = mysql_query($updateSQL, $comments) or die(mysql_error());
$updateGoTo = "office_index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
mysql_select_db($database_comments, $comments);
$query_users = "SELECT * FROM users";
$users = mysql_query($query_users, $comments) or die(mysql_error());
$row_users = mysql_fetch_assoc($users);
$totalRows_users = mysql_num_rows($users);
$colname_office = "-1";
if (isset($_GET['id'])) {
$colname_office = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_comments, $comments);
$query_office = sprintf("SELECT id, main_office, main_office_manager, main_office_manager_email, main_office_poc, main_office_poc_email FROM offices WHERE id = %s", $colname_office);
$office = mysql_query($query_office, $comments) or die(mysql_error());
$row_office = mysql_fetch_assoc($office);
$totalRows_office = mysql_num_rows($office);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="../../css/comments.css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CRITIC · Admin Index</title>
</head>
<body onload="document.office.main_office.focus()">
<table width="850" border="0" align="center" cellpadding="4" cellspacing="0" class="main_table">
<tr>
<td valign="bottom"> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td valign="bottom" class="login">Currently logged in: <? echo $_SESSION['MM_Username']?> |
<a href="<?php echo $logoutAction ?>">Log out</a> | <a href="http://steelhead/interactive/forum/comments/admin/users/change_pwd.php?user=<? echo $_SESSION['MM_Username'];?>">Profile</a></td>
<td colspan="2" rowspan="2"><table width="428" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td><div align="right"><img src="../../images/headers/header_CRITIC_main.gif" width="428" height="70" /></div></td>
</tr>
</table></td>
</tr>
<tr>
<td valign="bottom"><table border="0" cellspacing="0" cellpadding="2">
<tr>
<td width="14%"><div align="center"><a href="../../admin/admin_index.php"><img src="../../images/navbar/home.gif" alt="home" width="49" height="49" border="0" /></a></div></td>
<td width="14%"><div align="center"><a href="../../admin/reports/report_index.php"><img src="../../images/navbar/reports.gif" alt="reports" width="49" height="49" border="0" /></a></div></td>
<td width="14%"><div align="center"><a href="../../admin/offices/office_index.php"><img src="../../images/navbar/offices.gif" alt="offices" width="49" height="49" border="0" /></a></div></td>
<td width="14%"><div align="center"><a href="../../admin/users/user_index.php"><img src="../../images/navbar/users.gif" alt="users" width="49" height="49" border="0" /></a></div></td>
<td width="14%"><div align="center"><img src="../../images/navbar/search.gif" alt="search" width="49" height="49" /></div></td>
<td width="14%"><div align="center"><img src="../../images/navbar/print.gif" alt="print" width="49" height="49" /></div></td> <td width="14%"><div align="center"><a href="../../admin/bug_tracker/bug_tracker_index.php"><img src="../../images/navbar/input.gif" alt="admin" width="49" height="49" border="0" /></a></div></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="3"><hr width="100%" size="1" /></td>
</tr>
<tr>
<td colspan="3">Create Main Office:
<form action="<?php echo $editFormAction; ?>" id="office" name="office" method="POST">
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td colspan="2">Managers and POC's can be anyone, but in order for these individuals to access the system, they must be created through the <a href="../users/create_user.php">Create User</a> page. Otherwise, they will simply be listed for informational purposes on the <a href="office_index.php">Office Index</a> page. Be sure to assign the appropriate Admin Level when creating their user accounts.</td>
</tr>
<tr>
<td width="8%"> </td>
<td width="92%"> </td>
</tr>
<tr>
<td><div align="right"><strong>
Name: </strong></div></td>
<td><input name="main_office" type="text" id="main_office" onChange="javascript:this.value=this.value.toUpperCase();" value="<?php echo $row_office['main_office']; ?>" />
<strong>*</strong></td>
</tr>
<tr>
<td><div align="right"><strong>Manager:</strong></div></td>
<td><input name="main_office_manager" type="text" id="main_office_manager" value="<?php echo $row_office['main_office_manager']; ?>" />
<strong>*</strong></td>
</tr>
<tr>
<td><div align="right"><strong>Manager Email: </strong></div></td>
<td><input name="main_office_manager_email" type="text" id="main_office_manager_email" value="<?php echo $row_office['main_office_manager_email']; ?>" />
<strong>*</strong></td>
</tr>
<tr>
<td><div align="right"><strong>POC:</strong></div></td>
<td><input name="main_office_poc" type="text" id="office_poc" value="<?php echo $row_office['main_office_poc']; ?>" />
<strong>*</strong></td>
</tr>
<tr>
<td><div align="right"><strong>POC Email: </strong></div></td>
<td><input name="main_office_poc_email" type="text" id="office_poc_email" value="<?php echo $row_office['main_office_poc_email']; ?>" />
<strong>*</strong></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><strong>*</strong> Required </td>
<td> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input name="id" type="hidden" id="id" value="<?php echo $row_office['id']; ?>" />
<input type="submit" name="Submit" value="Submit" />
</div></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="office">
</form>
</td>
</tr>
</table>