Please help.
I am trying to select some information from the first table and insert information selected from the first table into the second table row by row. My code is shown below:
//////////////////////////////////////////////////////////////////////
if (isset($Test))
{
include (“dbConnection.php”);
$sql = “select * from check where paymentAmount=’18′”;
if (! $result = mysql_query($sql))
{
die(“bad query”);
}
while ($row = mysql_fetch_assoc($result))
{
$championID = $row[“championID”];
$paymentAmount = $row[“paymentAmount”];
$dateSent = $row[“dateSent”];
$dateReceived = $row[“dateReceived”];
$sql = “insert into mailing_check values (‘$championID’, ‘$paymentAmount’, ‘$dateSent’, ‘$dateReceived’)”;
if (! $result = mysql_query($sql))
{
die(“bad query.”);
}
} // End while
} // End if (isset($Test))
////////////////////////////////////////////////////////////////
I know that there should be 4 rows of record selected from the check table like this:
0010, 18.00, 2004-06-17, 2004-06-19
0017, 18.00, 2004-06-23, 2004-06-24
0030, 18.00, 2004-07-12, 2004-07-14
0036, 18.00, 2004-07-13, 2004-07-15
However, it only inserts the first row:
“0010, 18.00, 2004-06-17, 2004-06-19”
into mailing_check table instead of all 4 rows.
I don’t know why it inserts only the first row but not all 4 rows. Anyone know what I did wrong in my code?
Thanks very much