keymasterviriya1150

tableorder

Apr 12th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.12 KB | None | 0 0
  1. <html>
  2.     <head></head>
  3.     <body>
  4.  
  5. <?php
  6.     $data=array("ลำดับ","รหัสรายการ","ประเภท","จำนวน"   );
  7.     $datatable=array
  8.     (
  9.         array(1,"001","นมสด",0),
  10.         array(2,"002","ชาเขียว",0),
  11.         array(3,"003","ชานมชูมพู",0),
  12.         array(4,"004","ชาเย็น",0),
  13.         array(5,"005","โอวัลติน",0),
  14.         array(6,"006","โกโก",0),
  15.     );
  16.     echo"<table border=1>";
  17.         echo"<tr>";
  18.             for($i=0; $i<count($data) ; $i++)
  19.                 echo"<td>".$data[$i]."</td>";  
  20.         echo"</tr>";
  21.        
  22.         for($k=0 ;$k < count($_POST['user_pass']) ; $k++)
  23.             {
  24.                 if(trim($_POST['user_pass'][$k]) !="")
  25.                     $datatable[$k][3]=$_POST['user_pass'][$k];     
  26.             }
  27.             for($i=0; $i< 6; $i++)
  28.             {
  29.                 echo"<tr>";
  30.                 for($j=0; $j< 4  ; $j++)
  31.                     echo"<td>".$datatable[$i][$j]."</td>"; 
  32.                 echo"</tr>";
  33.             }  
  34.     echo"</table>";
  35.  
  36.     $sum=array(0,0,0,0,0,0);
  37.     for($i=0; $i<6 ; $i++)
  38.         $sum[$i]=$sum[$i]+$datatable[$i][3];
  39.    
  40.     /*for($i=0; $i<6 ; $i++)
  41.         echo $sum[$i]."<br/>";
  42.     echo "===================<br/>";*/
  43.    
  44.     $price=array(0,0,0,0,0,0);
  45.     $p=array(35,40,40,35,35,35);
  46.     for($i=0; $i<6 ; $i++)
  47.         $price[$i]=$p[$i]*$datatable[$i][3];
  48.     /*for($i=0; $i<6 ; $i++)
  49.         echo $price[$i]."<br/>";    */
  50.     $con=mysqli_connect("localhost","root","","testorder");
  51.    
  52.     /*if($con!=null)
  53.         echo"Sucess";*/
  54.      for($i=0; $i<6 ; $i++)
  55.      {
  56.          $a=$i+1;
  57.          $result=mysqli_query($con,"UPDATE  orders SET No ='".$sum[$i]."',ResultPrice='".$price[$i]."' WHERE ID='".$a."'  ");
  58.      }
  59.      
  60.    
  61.     $result=mysqli_query($con,"SELECT * FROM  orders");
  62.     /*if(!$result)
  63.         die("connot");*/
  64.     echo"<br/><br/>";
  65.    
  66.     $data1=array("ID","name","No","Price"," ResultPrice");
  67.     echo"<table border=1>";
  68.         echo"<tr>";
  69.             for($i=0; $i<count($data1) ; $i++)
  70.                 echo"<td>".$data1[$i]."</td>"; 
  71.         echo"</tr>";
  72.    
  73.         while($row=mysqli_fetch_array($result,MYSQLI_NUM))
  74.        {
  75.            echo "<tr>";
  76.            for($i=0;$i<5;$i++)
  77.                echo"<td>".$row[$i]."</td>";
  78.            echo "</tr>";
  79.        }
  80.         echo"</tr>";
  81.     echo"</table>";    
  82. ?>
  83.  
  84.     </body>
  85.     </html>
  86.  
  87. <body bgcolor="#33cc99">
Advertisement
Add Comment
Please, Sign In to add comment