我想通过提交按钮
在两个表的相同数据库中插入相同的值<table>
<form action="" method="post">
<tr>
<td> <input type="text" name="name" id="name" /> </td>
<td> <input type="submit" name="submit" id="submit" value="submit" /> </td>
</tr>
</form>
</table>
$conn = mysqli_connect('localhost','root','','dbname');
if(isset($_POST["submit"]))
{
$name= $name1 = $_POST["name"];
$query1= "insert into course (name) values ('$name')";
$result1 = mysqli_query($conn,$query1);
if (mysqli_num_rows($result1))
{
echo "run";
}else{
echo "not";
}
$query2= "insert into user (name) values ('$name1')";
$result2 = mysqli_query($conn,$query2);
if (mysqli_num_rows($result2) )
echo "run";
}else{
echo "not";
}
}
我收到警告: -
警告:mysqli_query():无法在第33行的D:\ Xampp \ xampp \ htdocs \ join_query \ insert.php中获取mysqli
警告:mysqli_num_rows()期望参数1为mysqli_result,在第35行的D:\ Xampp \ xampp \ htdocs \ join_query \ insert.php中给出null
不
警告:mysqli_query():无法在第46行的D:\ Xampp \ xampp \ htdocs \ join_query \ insert.php中获取mysqli
警告:mysqli_num_rows()要求参数1为mysqli_result,在第48行的D:\ Xampp \ xampp \ htdocs \ join_query \ insert.php中给出null
不