php - How to get user information and item into the same table in the database -
this question has answer here:
i need assistance trying information orders looping through. need able order information above user information user information form, can submit items , user information database . looks need submit multiple items attached user ordered it.
here partial code
if(isset($_post["get_cart_product"]) || isset($_post["cart_checkout"])){ $uid = $_session["uid"]; $sql = "select * cart user_id = `$uid` "; $run_query = mysqli_query($con,$sql); $count = mysqli_num_rows($run_query); if($count > 0){ $no = 1; $total_amt = 0; while($row=mysqli_fetch_array($run_query)){ $id = $row["id"]; $pro_id = $row["p_id"]; $pro_name = $row["product_title"]; $pro_image = $row["product_image"]; $qty = $row["qty"]; $pro_price = $row["price"]; $total = $row["total_amt"]; $price_array = array($total); $total_sum = array_sum($price_array); $total_amt = $total_amt + $total_sum; setcookie("ta",$total_amt,strtotime("+1 day"),"/","","",true); if(isset($_post["get_cart_product"])){ echo " <div class='row'> <div class='col-md-3 col-xs-3'>$no</div> <div class='col-md-3 col-xs-3'><img src='assets/product_images/$pro_image' width='60px' height='50px'></div> <div class='col-md-3 col-xs-3'>$pro_name</div> <div class='col-md-3 col-xs-3'>$.$pro_price.00</div> </div> "; $no = $no + 1; }else{ echo " <div class='row'> <div class='col-md-2 col-sm-2'> <div class='btn-group'> <a href='#' remove_id='$pro_id' class='btn btn-danger btn-xs remove'><span class='glyphicon glyphicon-trash'></span></a> <a href='' update_id='$pro_id' class='btn btn-primary btn-xs update'><span class='glyphicon glyphicon-ok-sign'></span></a> </div> </div>"; echo" <form action='user_information.php' id='form1' method='post'> <div class='col-md-2 col-sm-2'><img src='assets/product_images/$pro_image' width='50px' height='60'></div> <div class='col-md-2 col-sm-2'><input name='name' type='text' class='form-control qty' pid='$pro_name ' id='qty-$pro_name ' value='$pro_name ' ></div> <div class='col-md-2 col-sm-2'><input name='qty' type='text' class='form-control qty' pid='$pro_id' id='qty-$pro_id' value='$qty' ></div> <div class='col-md-2 col-sm-2'><input name='price' type='text' class='form-control price' pid='$pro_id' id='price-$pro_id' value='$pro_price' disabled></div> <div class='col-md-2 col-sm-2'><input name ='total' type='text' class='form-control total' pid='$pro_id' id='total-$pro_id' value='$total' disabled></div> </div>"; } } echo" <h3>employee information</h3> <label>lan id</label> <input type='text' name='lanid' id='lanid' autocomplete='off' class='form-control' > <label>employee name</label> <input type='text' name='employeename' id='name' autocomplete='off' class='form-control'> <label>department</label> <select name='department' id='department' class='form-control'> <option value =''>select department...</option> <option value ='other'> other</option> </select> <label>cost center</label> <input type='text' class='form-control' name='costcenter' value=''> <br><br><br> <input type='submit' class='btn btn-primary' value='submit'> </form>";
you can not use single-quoted ' integer variable. read more when use single quotes, double quotes, , backticks in mysql
use of query
$sql = "select * cart user_id = `$uid` ";
instead of this
$sql = "select * cart user_id = '$uid'";
Comments
Post a Comment