I tried multiple times but have been stucked for long time, kindly mention that which method is better S_SESSION or GET Method to used some variable as global. And how to
$date = date('Y-m-d H:i:s');
convert this into SESSION[] ,or as global to access on other pages. Other thing is that how to acces
$i
which is used as order_id , i wanna to used this as my invoice number. How can it is possible The code is give below
<?php include ('header.php');
if(isset($_POST['order']))
{
$user_id = $_SESSION['id'];
$date = date('Y-m-d H:i:s');
$username =$_SESSION['username'];
mysql_query("INSERT INTO tborder(user_id,`date`,username) VALUES('$user_id','$date','$username')") or die(mysql_error());
$i = mysql_insert_id();
if($i >0)
for($l=0;$l<count($_POST['product_id']);$l++)
{
$product_id = $_POST['product_id'][$l];
$quantity = $_POST['quantity'][$l];
$price = $_POST['price'][$l];
$discount = $_POST['discount'][$l];
$amount = $_POST['amount'][$l];
$username = $_SESSION['username'];
$user_id = $_SESSION['id'];
mysql_query("INSERT INTO tborderdetail(order_id,product_id,quantity,price,discount,amount,username,user_id) VALUES('$i','$product_id','$quantity','$price','$discount','$amount','$username','$user_id')")or die(mysql_error());
header('location:order.php');
}
}
?>
<form action="" method="post">
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div id="Tabs" role="tabpanel">
<!--- Nav Tabs -->
<ul class="nav nav-tabs" role="tablist">
<?php
$q =mysql_query("SELECT * FROM tbcategory");
while($row =mysql_fetch_object($q))
{
?>
<li class="">
<a href="#<?=$row->id?>" aria-controls="personal" role="tab" data-toggle="tab"><?=$row->category_name?></a>
</li>
<?php
}
?>
</ul>
<!--Tab Panes-->
<div class="tab-content" style="padding-top: 20px">
<?php
$q=mysql_query("SELECT * FROM tbcategory");
while($row = mysql_fetch_object($q))
{
?>
<div role="tabpanel" class="tab-pane" id="<?=$row->id?>">
<?php
$p =mysql_query("SELECT * FROM tbproduct WHERE cat_id = '$row->id'");
while($r = mysql_fetch_object($p))
{
?>
<div class="col-md-4">
<a class="datavalue" href="#" data-id="<?=$r->id?>" data-name="<?=$r->product_name?>" data-price="<?=$r->unit_price ?>">
<img width="100" height="100" src="product/<?=$r->image?>">
<h5><?=$r->product_name?></h5>
</a>
</div>
<?php
}
?>
</div>
<?php
}
?>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<table class="table">
<center><h2>MY PRODUCT</h2></center>
<tr>
<?php
date_default_timezone_set('Asia/Karachi');
$currenttime = date('h:i A');
?>
<td>
<label>Inv Date : </label>
<?= date('d-M-Y'); ?>
</td>
<td>
<label>Inv Time : </label>
<?=$currenttime ?>
</td>
</tr>
<tr>
<td>
<label>Inovice No.</label>
????
</td>
<td>
<label>User Name</label>
<?=$_SESSION['username'] ?>
</td>
</tr>
</table>
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>ProductName</th>
<th>Quantity</th>
<th> Price </th>
<th>Discount</th>
<th>Amount</th>
<th>X</th>
</tr>
</thead>
<tbody class="details">
</tbody>
<tfoot>
<tr>
<td>
SubTotal : <input type="text" name="subtotal" class="form-control subtotal">
Cash Receive: <input type="text" name="pay" class="form-control pay">
Pay Back : <input type="text" name="payback" class="form-control payback">
</td>
</tr>
</tfoot>
</table>
<input type="submit" name="order" value="Order" class="btn btn-primary">
</div>
</div>
</form>
<?php include ('footer.php') ;?>
Aucun commentaire:
Enregistrer un commentaire