我的数据库中有两个表,一个是“test1”,第二个是“test2”。 并且测试1的字段是“id”,“survey_no”,“lastname”,对于测试字段,我有“id”,“survey_no”,“address”,test1和test2的id是主键,并设置为auto -increment ..我想要的是,我在test1中的“survey_no”中插入的内容也应该插入“test_no in test2”中插入..有人可以帮我吧..请...
我这里有一个名为sample.php的插入代码
<!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" class="signin" action="" name="add" id="form1">
<fieldset class="textbox">
<label class="province_id">
<span>province id</span>
<input id="province" name="survey_no" type="number" value="" autocomplete="on" placeholder="survey_no">
</label>
<label class="municipality">
<span>Municipality</span>
<input id="municipality" name="lastname" value="" type="text" autocomplete="on" placeholder="lastname">
</label>
<br />
<br />
<button id="submit" type="submit" name="submit">Save</button>
<button id="submit" type="reset" name="reset">Reset</button>
</fieldset>
<?php
$conn=mysql_connect('localhost','root','');
if(!$conn)
{
die('could not connect:' .mysql_error());
}
mysql_select_db("sample",$conn);
if(isset($_POST['submit']))
{
$survey_no=$_POST['survey_no'];
$lastname=$_POST['lastname'];
$result = mysql_query("INSERT INTO `test1`(survey_no,lastname)
VALUES ('$survey_no','$lastname')");
if($result)
{
echo "<script type=\"text/javascript\">".
"alert('Saved!');".
"</script>";
}
else{
echo "<script type=\"text/javascript\">".
"alert('Failed!');".
"</script>";
}
}
?>
</form>
</body>
</html>
答案 0 :(得分:4)
results=api.search(q="microsoft",count=100)
print type(results)
print json.load(results)