php代码从两个表单中获取值并将其插入表中
我一页有两张表格。第一种方法是根据小组来取学生的名字。第二个表单用于单独输入标记。现在我想插入他们的标记,但没有成功。请帮我解决这个问题。我的代码是:php代码从两个表单中获取值并将其插入表中,php,Php,我一页有两张表格。第一种方法是根据小组来取学生的名字。第二个表单用于单独输入标记。现在我想插入他们的标记,但没有成功。请帮我解决这个问题。我的代码是: $faculty = null; //declare vars $link = mysql_connect('localhost', 'root', ''); if (!$link) { die('Not connected : ' . mysql_error()); } mysql_select_db('Sims', $link) or di
$faculty = null; //declare vars
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('Not connected : ' . mysql_error());
}
mysql_select_db('Sims', $link) or die("cannot select DB");
if(isset($_POST["faculty"]))
{
$faculty = $_POST["faculty"];
}
?>
<script language="JavaScript">
function autoSubmit()
{
var formObject = document.forms['theForm'];
formObject.submit();
}
</script>
<form name="theForm" method="post">
<select name="faculty" onChange="autoSubmit();">
<option value="null"></option>
<option value="computer" <?php if($faculty == 'computer') echo " selected"; ?>>Computer</option>
<option value="commerce" <?php if($faculty == 'commerce') echo " selected"; ?>>Commerce</option>
</select>
<br><br>
<?php
if($faculty =='computer')
{
echo "<select name=\"name\">";
$sql = mysql_query("SELECT name FROM std_reg where faculty= 'computer' ") or die(mysql_error());
while($row = mysql_fetch_array($sql)){
echo "<option>".$row[name]."</option>";}
echo "</select>";
}
if($faculty =='commerce')
{
echo "<select name=\"name\">";
$sql = mysql_query("SELECT name FROM std_reg where faculty= 'commerce' ") or die(mysql_error());
while($row = mysql_fetch_array($sql)){
echo "<option>".$row[name]."</option>";}
echo "</select>";
}
?>
<br><br>
</form>
<form method="post">
math <input type="text" name="urdu" />
science <input type="text" name="science" />
social <input type="text" name="social" />
<a href="insertmarks.php">submit</a>
</form>
$faculty=null//申报VAR
$link=mysql\u connect('localhost','root','');
如果(!$link){
die('未连接:'.mysql_error());
}
mysql_select_db('Sims',$link)或die(“无法选择db”);
如果(isset($_POST[“教员”]))
{
$faculty=$_POST[“faculty”];
}
?>
函数autoSubmit()
{
var formObject=document.forms['theForm'];
formObject.submit();
}
>商业
是否返回了错误,或者错误到底是如何失败的?事实上,问题是它只需要乌尔都语科学和社会分数,而不需要学生和教师的姓名。当我创建insert.php代码时。