2017-02-26 213 views
-2

我有一個表格,它有兩個部分,一個是信息,第二個是用戶可以檢查的長列表。下面是代碼:如何在mysql中的多個表中插入大量數據

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
</head> 

<body> 
<form method="post"> 
<h1> Basic Info </h1> 
<input type="text" name="title" /> 
<input type="text" name="city" /> 
<input type="text" name="location" /> 
<input type="text" name="type" /> 
<h1> Features </h1> 
<input name="feature" type="radio" /> 
<input name="feature" type="radio" /> 
<input name="feature" type="radio" /> 
<input name="feature" type="radio" /> 
<input name="feature" type="radio" /> 
<input name="feature" type="radio" /> 
<input name="feature" type="radio" /> 
<input name="feature" type="radio" /> 
<input name="feature" type="radio" /> 
<input name="feature" type="radio" /> 
<input name="feature" type="radio" /> 
<input name="feature" type="radio" /> 
<input name="feature" type="radio" /> 
<input name="feature" type="radio" /> 
<input name="feature" type="radio" /> 
<input name="feature" type="radio" /> 
</form> 
</body> 
</html> 

和我有兩個表(p_detail和p_feature),我希望該用戶的基本信息p_detail表和要素插入插入p_feature表。 我的p_feature表中有以下列(id,property_id,features)和我的p_detail(id,title,location,city等等)。主要問題是在p_feature表中,我希望id在p_detail中應該是相同的在p_feature中的property_id。我怎麼能這樣做?

問候

回答

0

假設 '身份證' 是p_deatil增量主鍵,

插入 'p_detail',你得到的INSERT_ID像,後

$id_p_detail = $mysqli->insert_id;