如何在mysql

时间:2017-02-26 15:03:59

标签: php mysql sql

我有一个有两个部分的表单,一个用于信息,第二个是用户可以查看的长列表。这是代码:

<!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表,我希望p_detail中的id在property_id中应该是相同的在p_feature中。我怎么能这样做?

问候

1 个答案:

答案 0 :(得分:0)

假设'id'是p_deatil中的增量主键,

插入'p_detail'后,您将获得insert_id like,

$id_p_detail = $mysqli->insert_id;