如何使用php将组合框值插入到mysql数据库中

时间:2017-09-08 14:03:36

标签: php mysql combobox

所以我想将组合框值插入数据库。从tbl_supplier中检索组合框值,并从中我想将所选项插入到其他表中,即tbl_product。

这是我的代码:

     <?php
      include_once 'dbconfig.php';
      ....

    if (!empty($_FILES["uploadedimage"]["name"])) { //for inserting image


...

         $product_supplier = $_POST['product_supplier']; // having problem with this line, i think?

...

         $imagename=$_FILES["uploadedimage"]["name"];
         $target_path = "img/".$imagename;


    if(move_uploaded_file($temp_name, $target_path)) {



      $query_upload="INSERT into tbl_product(product_supplier) VALUES 
      ('$product_supplier')";
      mysql_query($query_upload) or die("error in $query_upload == ----> ".mysql_error());  



    }else{  

       exit("Error While uploading image on the server");
    } 

    }

 <select name="product_supplier">
                          <?php
                          $q1 = mysql_query("select * from tbl_supplier");
                          while($test = mysql_fetch_array($q1))
                            $supplier_name  = $test["supplier_name"];
                          {

                            ?>  

                            <option value="<?php echo $supplier_name?>"><?php echo $supplier_name ?> </option>
                            <?php

                            }


                          ?>
                          </select> 

帮助我,急需解决这个问题。打开任何建议或代码语法。提前谢谢!

0 个答案:

没有答案