I'm still having trouble trying to get info from a form and a table entered into a second table.
Here's how I want it to work.
-people enter business info into a form
-that info is entered into table1
-a business key is selected from table1
-the business key and zip codes are entered into table2
(one record for each zip code)
I'm able to enter all the business info into table1 and select the business key.
The problem comes when I try to enter the zip codes. All I get is a new record with one zip code and a 0 for the BusinessKey.
For the INSERT statement I've tried using ".$row['BusinessKey']." or '.$row['BusinessKey'].' instead of '$BusinessKey' and echo $row['BusinessKey'];
And, I know I need a while statement on the INSERT but can't figure out how to write one that works.
Any help would be greatly appreciated as really having a tough time with this.
Thanks,
TC
FIRST PAGE
(This is actually the second page...after the form where people enter their business info)
<?php
session_start();
?>
<html>
<head>
<title>Untitled Document</title>
<?php
session_register ("BusinessName");
session_register ("ContactName");
session_register ("Phone1");
?>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="insert_zipcodes.php">
<input type="text" name="zipcode">
<input type="text" name="zipcode">
<input type="text" name="zipcode">
<input type="text" name="zipcode">
<input type="text" name="zipcode">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
SECOND PAGE
<?php
session_start();
session_unregister("BusinessName");
session_unregister ("ContactName");
session_unregister ("Phone1");
?>
<html>
<head>
<title>insert_zipcodes.php</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");
$query = "SELECT BusinessKey FROM tblMain WHERE BusinessName='$BusinessName' AND ContactName='$ContactName' AND Phone1='$Phone1'";
$resultID = mysql_query($query) or die("Invalid query query 1: " . mysql_error());
while ($row = mysql_fetch_assoc($resultID))
{
echo $row['BusinessKey'];
}
$BusinessKey = "$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);
?>