php - How to insert (order form data) in multiple rows of mysql having same name -


here code.

<form id="form.id" name="form.id" action="order" method="post">   <ul>      //loading dynamically javascript      <li class="singalproductlist'+ productid +'">         <input type="text" value="'+ productid +'" name="dishid[]" disabled>         <input class="newlass'+ productid +'" type="text"                        value="1" name="dishquantity[]" disabled>         <input type="text" value="'+ name +'" name="dishname[]" disabled>         <input type="text" value="'+ price +'" name="dishprice[]" disabled>     </li>   </ul> </form> 

i using mvc that's why action (order) only.

i submitting other button javascript not shown here.

i able single li having 4 input fields value without [ ].

when use [ ] error occur: notice: undefined index: dishname in .....

i have used every code that's why can't show particular one.

li can 5 or 6 no limit.

i can use productid in every name inside [ ].

i want insert every li have 4 inputs in 1 row , others in next row in mysql.

i have problem php side.

thank in advanced in case of help.

php code dishid , dishname,

$dishids = $_post['dishid']; $dishnames = $_post['dishname'];  $query = $con1->prepare("insert dishes (dish_id, dish_name) values (?, ?)");      ($i=0; $i<count($dishid); $i++) {          $dishid = $dishids[$i];         $dishname = $dishnames[$i];          $query->bind_param('ssi', $dishid, $dishname);         $query->execute();     }      echo "done";     $query->close(); 

here working php code processing order form data , insert in mysqli using php.

include 'includes/db.php';      $did = $_post['dishid'];     $dqty = $_post['dishquantity'];     $dname = $_post['dishname'];     $dprice = $_post['dishprice'];      $totaldishes = sizeof($did);      for($i=0;$i<$totaldishes;$i++) {        $insertdid = $did[$i];       $insertdqty = $dqty[$i];       $insertdname = $dname[$i];       $insertdprice = $dprice[$i];        $sql = "insert test (dish_id, dish_quantity ,dish_name ,dish_price)       values ('$insertdid','$insertdqty','$insertdname','$insertdprice') ";        if ($con1->query($sql) === true) {         echo "new record created <br />";       } else {         echo "error: " . $sql . "<br>" . $con1->error;       }     } 

if interested , need more code or can ask.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -