Ok, I was able to get my notes section to display properly with the above help, but when I click the submit button all it does is clear the page still and not update my database. I've tried adding a separate 'cid' key for all my other tables and updated all the php so that all my scripts try and call it up from that rather than just 'id', but now it refuses to display anything besides what is in my "name" table, which is the only one which is queried using the 'id' key.
Here's my old php script, which still displays everything with my new tables and data but still wont post to my database:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Edit Customer Information</title>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
$dbcnx = @mysql_connect('127.0.0.1:3306', 'root', '');
if (!$dbcnx) {
exit('<p>Unable to connect to the ' .
'database server at this time.</p>');
}
if (!mysql_select_db('customer')) {
exit('<p>Unable to locate the Customer ' .
'database at this time.</p>');
}
if (isset($_POST['f_name'])):
// The customer's information has been updated.
$f_name = $_POST['f_name'];
$l_name = $_POST['l_name'];
$ssn = $_POST['ssn'];
$id = $_POST['id'];
$sql = "UPDATE name SET
f_name='$f_name',
l_name='$l_name',
ssn='$ssn'
WHERE id='$id'";
if (mysql_query($sql)) {
echo '<p>Customer information details updated.</p>';
} else {
echo '<p>Error updating Customer information details: ' .
mysql_error() . '</p>';
}
$address = $_POST['address'];
$city = $_POST['city'];
$state= $_POST['state'];
$zip= $_POST['zip'];
$id = $_POST['id'];
$sql = "UPDATE address SET
address='$address',
city='$city',
state='$state'
zip='$zip',
WHERE id='$id'";
if (mysql_query($sql)) {
echo '<p>Customer information details updated.</p>';
} else {
echo '<p>Error updating Customer information details: ' .
mysql_error() . '</p>';
}
$tel_number= $_POST['tel_number'];
$tel_type = $_POST['tel_type'];
$id = $_POST['id'];
$sql = "UPDATE telephone SET
tel_number='$tel_number',
tel_type='$tel_type'
WHERE id='$id'";
if (mysql_query($sql)) {
echo '<p>Customer information details updated.</p>';
} else {
echo '<p>Error updating Customer information details: ' .
mysql_error() . '</p>';
}
$note= $_POST['note'];
$id = $_POST['id'];
$sql = "UPDATE p_note SET
note='$note'
WHERE id='$id'";
if (mysql_query($sql)) {
echo '<p>Customer information details updated.</p>';
} else {
echo '<p>Error updating Customer information details: ' .
mysql_error() . '</p>';
}
?>
<p><a href="customer.php">Return to Customer Information Page</a></p>
<?php
else: // Allow the user to edit the customer
$id = $_GET['id'];
$name = mysql_query(
"SELECT f_name, l_name, ssn FROM name WHERE id='$id'");
if (!$name) {
exit('<p>Error fetching customer details: ' .
mysql_error() . '</p>');
}
$cname = mysql_fetch_array($name);
$f_name = $cname['f_name'];
$l_name = $cname['l_name'];
$ssn = $cname['ssn'];
$id = $_GET['id'];
$addy = mysql_query(
"SELECT address, city, state, zip FROM address WHERE id='$id'");
$caddy = mysql_fetch_array($addy);
$address = $caddy['address'];
$city = $caddy['city'];
$state= $caddy['state'];
$zip = $caddy['zip'];
$id = $_GET['id'];
$tel = mysql_query(
"SELECT tel_number, tel_type FROM telephone WHERE id='$id'");
$ctel = mysql_fetch_array($tel);
$tel_number = $ctel['tel_number'];
$tel_type = $ctel['tel_type'];
$id = $_GET['id'];
$not = mysql_query(
"SELECT id, note FROM p_note WHERE id='$id'");
$cnot = mysql_fetch_array($not);
$note = $cnot['note'];
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<p>Edit the Customer's History:</p>
<P><strong>First/Last Names:</strong><br>
<input type=\"text\" name=\"f_name\" value="<?php echo $f_name; ?>" />
<input type=\"text\" name=\"l_name\" value="<?php echo $l_name; ?>" />
<P><strong>Social Security Number:</strong><br>
<input type=\"text\" name=\"ssn\" value="<?php echo $ssn; ?>" />
<P><strong>Address:</strong><br>
<input type=\"text\" name=\"address\" value="<?php echo $address; ?>" />
<P><strong>City/State/Zip:</strong><br>
<input type=\"text\" name=\"city\" value="<?php echo $city; ?>" />
<input type=\"text\" name=\"state\" value="<?php echo $state; ?>" />
<input type=\"text\" name=\"zipcode\" value="<?php echo $zip; ?>" />
<P><strong>Telephone Number:</strong><br>
<input type=\"text\" name=\"tel_number\" value="<?php echo $tel_number; ?>" />
<lable>Telephone type:</lable><input type=\"text\" name=\"tel_type\" value="<?php echo $tel_type; ?>" />
<P><strong>Personal Note:</strong><br>
<P><strong>Personal Note:</strong><br>
<textarea name=\"note\" cols=35 rows=5><?php echo $note; ?></textarea>
<br /><input type="hidden" name="id" value="<?php echo $id; ?>" />
<input type="submit" value="SUBMIT" /></p>
</form>
<?php endif; ?>
</body>
</html>