php - 使用 php 向 mysql 表添加多个值

标签 php html mysql database

我得到了这个代码

    <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/

相关文章:

php - Magento 在分层导航中使用所有属性

php - 如何从 php 邮件中删除 X-CMAE-Envelope

javascript - 滑入菜单 - Canvas 外

php - 如何使用 php mailer 将数据库数据作为电子邮件发送?

php - Zend Framework 基于 URL 的翻译路径

php - 忽略 MySQL Group By 值

html - 右侧的 CSS flex div 图片

html - 元素未居中。我用的是绝对?

php - MySQL > 更新查询在 PDO 类型时不起作用

mysql - 如何修改 MySQL 表中列的大小?