I have been wracking my brain all weekend trying to figure out if you can loop the results from one sql_result set, and then insert them all into another table dynamically.
Will this require two DB connections? Has anyone done this sort of thing before? My main idea is to check tbl1 for results that are 2 days or older:
$sql = "SELECT * FROM present where Status = 'Expired' and to_days(now()) - to_days(Dated) >= 2";
And then loop the results:
if (mysql_num_rows ($sql_result) > 0) {
while ($row = mysql_fetch_array($sql_result)) {
$id = $row["ID"];
$name = $row["Name"];
And then insert those looped results into tbl2:
$sql2 = "INSERT INTO past VALUES ('$id', '$name')";
For some reason either my logic is flawed or something is terribly wrong because I can't seem to get it to work.
Has anyone else ever attempted such? Mind showing me what you did?