mysql - Php foreach loop stops at PDO execute -


this page should add record database @ each loop. however, when loop reaches $stmt->execute(), loop stops. know opendb.php include should right, i've used before.

<!doctype html> <html lang="nl">     <head><link rel="stylesheet" type="text/css" href="style/style.css">         <title> afronden bestelling </title>      </head>     <body>         <div id="wrap">             <?php include_once ('includes/navigation.php'); ?>             <div id="main">                 <br>                 <br>                 <h1> ik ben leeg :( </h1>                  <?php                  // database name                 $dbname = "kledingwinkel";                 $factuurid = 1;                 $klantid = 42;                 $test = 20;                  // add record database:                 include("opendb.php");                 $stmt = $db->prepare('insert facturen ( productid, klantid, aantal, totaal, product_name ) values ( ?, ?, ?, ?, ? )');                 $stmt->bindvalue(1, $test, pdo::param_str);                 $stmt->bindvalue(2, $klantid, pdo::param_str);                 $stmt->bindvalue(3, $product_qty, pdo::param_str);                 $stmt->bindvalue(4, $subtotal, pdo::param_str);                 $stmt->bindvalue(5, $product_name, pdo::param_str);                   foreach ($_session["cart_products"] $cart_itm)                 {                     //set variables use in content below                     $product_name = $cart_itm["product_name"];                     $product_qty = $cart_itm["product_qty"];                     $product_price = $cart_itm["product_price"];                     $product_code = $cart_itm["product_code"];                     $product_size = $cart_itm["product_size"];                     $subtotal = ($product_price * $product_qty); //calculate price x qty                      echo $product_name;                     //echo $product_qty;                     //echo $product_price;                     //echo $product_code;                     //echo $product_size;                     //echo $subtotal;                       $stmt->execute();                 }                  ?>                  <br>                 <br>             </div>         </div>         <?php include_once ('includes/footer.php'); ?>     </body> </html> 

is able explain me what's going wrong? in advance.


Comments