<?php
//invoice.php
include('database_connection.php');
$statement = $connect->prepare("
SELECT * FROM tbl_order
ORDER BY order_id DESC
");
$statement->execute();
$all_result = $statement->fetchAll();
$total_rows = $statement->rowCount();
if(isset($_POST["create_invoice"]))
{
$order_item_tax1_rate = 0;
$order_item_tax1_amount = 0;
$order_item_tax2_rate = 0;
$order_item_tax2_amount = 0;
$order_item_hc = 0;
$order_item_final_amount = 0;
$statement = $connect->prepare("
INSERT INTO tbl_order
(order_no, order_date, order_receiver_name, order_receiver_gstin, order_item_tax1_rate, order_item_tax1_amount, order_item_tax2_rate, order_item_tax2_amount, order_item_hc_, order_item_final_amount, order_datetime)
VALUES (:order_no, :order_date, :order_receiver_name, :order_receiver_gstin, :order_item_tax1_rate, :order_item_tax1_amount, :order_item_tax2_rate, :order_item_tax2_amount, :order_item_hc, :order_item_final_amount, :order_datetime)
");
$statement->execute(
array(
':order_no' => trim($_POST["order_no"]),
':order_date' => trim($_POST["order_date"]),
':order_receiver_name' => trim($_POST["order_receiver_name"]),
':order_receiver_gstin' => trim($_POST["order_receiver_gstin"]),
':order_item_tax1_rate' => trim($_POST["order_item_tax1_rate"]),
':order_item_tax1_amount' => trim($_POST["order_item_tax1_amount"]),
':order_item_tax2_rate' => trim($_POST["order_item_tax2_rate"]),
':order_item_tax2_amount' => trim($_POST["order_item_tax2_amount"]),
':order_item_hc' => trim($_POST["order_item_hc"]),
':order_item_final_amount' => trim($_POST["order_item_final_amount"]),
':order_datetime' => date("Y-m-d")
)
);
$statement = $connect->query("SELECT LAST_INSERT_ID()");
$order_id = $statement->fetchColumn();
echo $order_id;
for($count=0; $count<$_POST["total_item"]; $count++)
{
$statement = $connect->prepare("
INSERT INTO tbl_order_item
(order_id, order_item_name, order_item_quantity, order_item_price, order_item_actual_amount)
VALUES (:order_id, :order_item_name, :order_item_quantity, :order_item_price, :order_item_actual_amount)
");
$statement->execute(
array(
':order_id' => $order_id,
':order_item_name' => trim($_POST["order_item_name"][$count]),
':order_item_quantity' => trim($_POST["order_item_quantity"][$count]),
':order_item_price' => trim($_POST["order_item_price"][$count]),
':order_item_actual_amount' => trim($_POST["order_item_actual_amount"][$count])
)
);
}
header("location:invoice.php");
}
this is my code
its not doslpaying any error
but its not inserting data into db