Advertisement
jamesmva

Untitled

Oct 18th, 2016
272
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. //ignore the inputs,there are there so i can post the values,because <td> does  not post.
  3. function cart(){
  4.     global $conn;
  5.  
  6.    
  7.     $fabric_options = '';
  8.     $query2 = "SELECT * FROM almofadas";
  9.     $result = mysqli_query($conn,$query2);
  10.     while($rows = mysqli_fetch_assoc($result)){
  11.        
  12.       $tecido=$rows['tecido'];
  13.       $id_price=$rows['id_price'];
  14.      
  15.       $t50='50';
  16.       $t45='45';
  17.       $fabric_options .= '<option value="'.$id_price.'" >'.$tecido.'</option>';
  18.  
  19.     }
  20.  
  21. $total = 0;
  22.  $all_products=0;
  23.     foreach ($_SESSION as $name => $value) {
  24.         if($value > 0){
  25.             if(substr($name, 0, 8 ) == "product_"){
  26.                 $length = strlen($name) -8;
  27.                 $item_id = substr($name,8 , $length);
  28.  
  29.                 $query = "SELECT *
  30.                          FROM gallery2
  31.                          WHERE gallery2.id =".escape_string($item_id). "";
  32.                 $run_item = mysqli_query($conn,$query);
  33.  
  34.                
  35.                
  36.                
  37.                
  38.     while($rows = mysqli_fetch_assoc($run_item)){
  39.         $vari   = $rows['variante'];
  40.         $num    = $rows['title'];
  41.         $id     = $rows['id'];
  42.  
  43.        
  44.        if(!isset($_SESSION['icms'.$id])) {
  45.         $_SESSION['icms'.$id]='0';
  46.         }else{
  47.         $_SESSION['icms'.$id];
  48.         }
  49.  
  50.          $btn_add ='<button type="button" class="btn btn-success actions plus" data-action="plus" product_id="'.$id.'"><i class="fa fa-plus fa-lg" aria-hidden="true" add_btn></i></button>';
  51.          $btn_remove ='<button type="button" class="btn btn-warning actions less" data-action="remove" product_id="'.$id.'"><i class="fa fa-minus fa-lg" aria-hidden="true" remove_btn></i></button>';
  52.          $btn_delete ='<button type="button" class="btn btn-default actions" data-action="delete" product_id="'.$id.'" onclick="deleteRow(this)"><i class="fa fa-times fa-lg" aria-hidden="true"></i></button>';
  53.  
  54.         if($rows['variante'] < 1){
  55.          $vari="";
  56.         }else{
  57.          $vari =$rows['variante'];
  58.         }
  59.  
  60.         $subtotal=$value * $_SESSION['icms'.$id];
  61.         $cost=$_SESSION['icms'.$id];
  62.         $all_products +=$value;
  63.  
  64.         $product = '
  65.        <tr>
  66.          <td style="width:100px; "><img src="../'.$rows['image'].'" style="width:90%;border: 1px solid black;"></td>
  67.          <td>'.$num.'-'.$vari.'</td>
  68.  
  69.          <input type="hidden" value="'.$num.'" name="numero">
  70.          <input type="hidden" value="'.$vari.'" name="vari">
  71.          <input type="hidden" value="'.$rows['image'].'" name="desenho">
  72.  
  73.          <td style="width:15%;">
  74.            <select name="fabric" class="fabric select form-control selectpicker" required="" data-id="'.$id.'"  >
  75.                '. $fabric_options . '  
  76.            </select>
  77.          </td>
  78.            
  79.          <td>
  80.            <select  data-id="'.$id.'" class="select size form-control selectpicker" required style="width:80%;"  name="size">
  81.              <option value="'.$t50.'" name="'.$t50.'">50x'.$t50.'</option>
  82.              <option value="'.$t45.'" name="'.$t50.'">45x'.$t45.'</option>
  83.                  
  84.            </select>
  85.          </td>
  86.          
  87.  
  88.          <td class="product'.$id.' " value="'.$value.'" type="text" >'.$value.'</td>
  89.          <input  type="hidden" name="qnty" value="'.$value.'"/>
  90.  
  91.          <td class="cost" data-id="'.$id.'" name="'.$cost.'">R$:'.$cost.'</td>
  92.          <input type="hidden" name="cost" value="'.$cost.'"/>
  93.  
  94.          <td class="subtotal" data-id="'.$id.'" >R$:'.number_format($subtotal, 2, '.', '') .'</td>
  95.          <input class="subtotal" type="hidden" name="subtotal" value="'.number_format($subtotal, 2, '.', '') .'"/>
  96.          <td>
  97.             '.$btn_add.' '.$btn_remove.' '.$btn_delete.'
  98.          </td>
  99.        </tr>';
  100.         echo $product;  
  101. /// closing brackets
  102.  
  103. ?>
Advertisement
RAW Paste Data Copied
Advertisement