我得到了这个代码
<form action="MyCurrentPage.php" method="post" >
<label for="name_of_trainer"> Name Trainer </label>
<input type="text" name="name_of_trainer" id="name_of_trainer"/>
<label for="double"> yearly Income </label>
<input type="text" name="yearly_income id="yearlyincome"/>
<input type= "submit" value="submit" name="submit" />
</form>
?php
if (isset($_POST['submit'])) {
$yearly_income_adition=$_POST['name_of_trainer'];
$yearly_income=$_POST['yearly_income'];
$mysqli->select_db("trainers");
$sql="INSERT INTO trainers (titleCD, yearly_income) VALUES ('".$yearly_income_adition."','".$yearly_income.'")";
$mysqli->query($sql);
}
?>
我正在使用它向我的数据库中插入新值,但它不起作用,没有添加值,而且我没有收到任何错误。我有语法错误吗?
最佳答案
你错过了两件事:
?php
应该是 <?php
和
'".$yearly_income.'")";
应该是 '".$yearly_income."')";
让我知道这是否适合您。
关于php - 使用 php 向 mysql 表添加多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36946125/