I'm having trouble figuring out how to do this. I've got a form that
enters info (Business Name, Contact, Phone, etc.) into a table in
my database. After that I get the business key that goes with
that business. There is a second form to enter zip codes - people
can enter up to 30 zip codes on this one page. I want to be able
to add zip codes into another table in the same database. I'm
posting the code below, and it works up to this
point:
{
echo $row['BusinessKey'];
}
It's not inserting the zip codes. What it does instead is inserts a
new record for every zip code I've entered but in the BusinessKey and Zip fields it's entering a 0.
(This is the last of 4 pages I've set up for this. The first 3 pages
work fine.)
<?php
session_start();
session_unregister("BusinessName");
session_unregister ("ContactName");
session_unregister ("Phone1");
session_unregister ("BusinessKey");
session_destroy();
?>
<html>
<head>
<title>Untitled Document</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
echo "$BusinessName<br>
$ContactName<br>
$Phone1<br>";
@ $db = mysql_connect("X", "X", "X");
if (!$db)
{
echo "Error: Could not connect. Please try again later.";
exit;
}
@mysql_select_db("X");
$sql = "SELECT BusinessKey FROM tblMain WHERE BusinessName='$BusinessName' AND ContactName='$ContactName' AND Phone1='$Phone1'";
$resultID = mysql_query($sql) or die("Invalid query query 1: " . mysql_error());
while ($row = mysql_fetch_assoc($resultID))
{
echo $row['BusinessKey'];
}
$query = "INSERT INTO tblZipCodes (BusinessKey, Zip) VALUES('BusinessKey', 'Zip')";
$resultID = mysql_query($query) or die("Invalid query query 2: " . mysql_error());
if ($result)
echo mysql_affected_rows()."<center><font face=Arial, Helvetica, sans-serif size=3><b>Your information has been submitted.
<br>
<br>
<a href='http://www.mywebsite.com'>Continue</center>";
mysql_close($linkID);
?>
</body>
</html>
Thanks!
TC