2017-09-12 2 views
1

Ich brauche Unterstützung, um die Informationen aus den Aufträgen zu erhalten, die ich durchlaufe. Ich muss in der Lage sein, diese Bestellinformationen über die Benutzerinformationen in das Benutzerinformationsformular zu bekommen, damit ich die Elemente und die Benutzerinformationen in die Datenbank einreichen kann. Aber es sieht so aus, als müsste ich dem Benutzer, der es bestellt hat, mehrere Artikel beifügen.So erhalten Sie Benutzerinformationen und Artikel in derselben Tabelle in der Datenbank

Hier ist der Teil-Code

if(isset($_POST["get_cart_product"]) || isset($_POST["cart_checkout"])){ 
      $uid = $_SESSION["uid"]; 
      $sql = "SELECT * FROM cart WHERE 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>"; 
+0

@fred wie gehe ich über diese Frage gelöscht bekommen. Der eine, der funktioniert hat, war die andere Frage – Donny

Antwort

0

Sie nicht einfachen Anführungszeichen ' für Integer-Variable verwenden. Lesen Sie mehr über dieses When to use single quotes, double quotes, and backticks in MySQL

Verwendung dieser Abfrage

$sql = "SELECT * FROM cart WHERE user_id = `$uid` "; 

Statt dieser

$sql = "SELECT * FROM cart WHERE user_id = '$uid'"; 
+0

Will tun, aber das beantwortet nicht meine Frage, wie die Schleife in mein Formular Bellow zu echo – Donny

Verwandte Themen