dongzhabo2796 2017-07-20 22:00
浏览 55


I am looking for help on storing data from multiple select form to MYSQL using PHP, here is my form

            <form action="" method="post">

            Choose your preferred browser
            <select name="browsers"> 
            <option value="Internet Explorer">
            <option value="Firefox">
            <option value="Chrome">
            <option value="Opera">
            <option value="Safari">

            Choose your preferred car
            <select name="carlist">
            <option value="volvo">Volvo</option>
            <option value="saab">Saab</option>
            <option value="opel">Opel</option>
            <option value="audi">Audi</option>

            <input type="submit">
  • 写回答

1条回答 默认 最新

  • doulu3808 2017-07-20 22:11

    $_POST['browser']; and $_POST['carlist']; each hold their own different value. So you can easily fetch each of their values.

    $car = $_POST['carlist'];
    $browser = $_POST['browser'];

    Now it's just a matter of question where you wanna take it from there. F.ex. if you'd like to save it to a database;

    // Just make it a standard to secure your database inputs
    $car = mysqli_real_escape_string($conn, $_POST['carlist']);
    $browser = mysqli_real_escape_string($conn, $_POST['browser']);
    $sql = "INSERT INTO someTable (car, browser) VALUES ('".$car."', '".$browser."')";
    mysqli_query($conn, $sql);

    This is very simplified of course, but I hope it gives you an idea.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 基于ucc28019的pfc电路中芯片一直不工作
  • ¥15 yolov8在3588板子端c++推理报错
  • ¥50 unitywebrequest分段下载导致报错,如何解决?
  • ¥15 错误使用 gretna_GUI_PreprocessInterface>RunBtn_Callback
  • ¥15 WPF如何用Chart绘画出Y轴的左边数据
  • ¥15 pycharm无法查看内置代码
  • ¥15 跑hls xfopencv的例程standalone_hls_axi_example出的错误,csim没问题,c synthesis出的错误
  • ¥15 sqlserver update语句逐行生效
  • ¥20 Windows10系统命令行调用
  • ¥15 php环境如何实现国密SM2相关功能