所以我需要将这条语句输出的所有行插入到单独的表中:
SELECT * FROM children WHERE quoteid = '$quoteid'
这仅插入其中一行:
INSERT INTO beneficiaries (quoteid, uid, name, percent) VALUES('$quoteid', '$uid', '$nm', '10')
任何人都知道移动多行的方法还是我必须单独发送它们?
更新:
之前应该提到过这一点,但不,'children' 没有相同的列名,更改它们不是一种选择。对不起!
$query = mysql_query("SELECT * FROM beneficiaries WHERE quoteid = '$quoteid'");
$getchildrenrid2 = mysql_fetch_assoc($query);
if(mysql_num_rows($query) == 0)
{
$getchildren = mysql_query("SELECT * FROM children WHERE quoteid = '$quoteid'");
$getchildrenrid = mysql_fetch_assoc($getchildren);
$nm = $getchildrenrid['first_name'] . " " . $getchildrenrid['surname'];
$query = mysql_query("INSERT INTO beneficiaries (quoteid, uid, name, percent) VALUES('$quoteid', '$uid', '$nm', '10')");
$query = mysql_query("SELECT * FROM beneficiaries WHERE quoteid = '$quoteid'");
$getlastchild = mysql_fetch_assoc($query);
header("Location: ".$conf['location']."/distribution.php?edit=".$getlastchild['id']);
}
“儿童”列:
- id
- **quoteid**
- **uid**
- *first_name*
- middle_names
- *surname*
- dob
- guardian_first_name
- guardian_middlenames
- guardian_nickname
- guardian_surname
- guardian_housenum
- guardian_city
- guardian_street
- guardian_postcode
“受益人”列
- id
- **quoteid**
- **uid**
- *name*
- **percent**
需要复制的内容:
- 报价单 INTO报价单
- uid 进入 uid
- 名字 + 姓氏 INTO 名字
- 并将百分比设置为“10”
此外,这应该只在此之后完成: SELECT * FROM children WHERE quoteid = '$quoteid' 完成。
$quoteid 返回当前报价的唯一quoteid。