Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head></head>
- <body>
- <?php
- $data=array("ลำดับ","รหัสรายการ","ประเภท","จำนวน" );
- $datatable=array
- (
- array(1,"001","นมสด",0),
- array(2,"002","ชาเขียว",0),
- array(3,"003","ชานมชูมพู",0),
- array(4,"004","ชาเย็น",0),
- array(5,"005","โอวัลติน",0),
- array(6,"006","โกโก",0),
- );
- echo"<table border=1>";
- echo"<tr>";
- for($i=0; $i<count($data) ; $i++)
- echo"<td>".$data[$i]."</td>";
- echo"</tr>";
- for($k=0 ;$k < count($_POST['user_pass']) ; $k++)
- {
- if(trim($_POST['user_pass'][$k]) !="")
- $datatable[$k][3]=$_POST['user_pass'][$k];
- }
- for($i=0; $i< 6; $i++)
- {
- echo"<tr>";
- for($j=0; $j< 4 ; $j++)
- echo"<td>".$datatable[$i][$j]."</td>";
- echo"</tr>";
- }
- echo"</table>";
- $sum=array(0,0,0,0,0,0);
- for($i=0; $i<6 ; $i++)
- $sum[$i]=$sum[$i]+$datatable[$i][3];
- /*for($i=0; $i<6 ; $i++)
- echo $sum[$i]."<br/>";
- echo "===================<br/>";*/
- $price=array(0,0,0,0,0,0);
- $p=array(35,40,40,35,35,35);
- for($i=0; $i<6 ; $i++)
- $price[$i]=$p[$i]*$datatable[$i][3];
- /*for($i=0; $i<6 ; $i++)
- echo $price[$i]."<br/>"; */
- $con=mysqli_connect("localhost","root","","testorder");
- /*if($con!=null)
- echo"Sucess";*/
- for($i=0; $i<6 ; $i++)
- {
- $a=$i+1;
- $result=mysqli_query($con,"UPDATE orders SET No ='".$sum[$i]."',ResultPrice='".$price[$i]."' WHERE ID='".$a."' ");
- }
- $result=mysqli_query($con,"SELECT * FROM orders");
- /*if(!$result)
- die("connot");*/
- echo"<br/><br/>";
- $data1=array("ID","name","No","Price"," ResultPrice");
- echo"<table border=1>";
- echo"<tr>";
- for($i=0; $i<count($data1) ; $i++)
- echo"<td>".$data1[$i]."</td>";
- echo"</tr>";
- while($row=mysqli_fetch_array($result,MYSQLI_NUM))
- {
- echo "<tr>";
- for($i=0;$i<5;$i++)
- echo"<td>".$row[$i]."</td>";
- echo "</tr>";
- }
- echo"</tr>";
- echo"</table>";
- ?>
- </body>
- </html>
- <body bgcolor="#33cc99">
Advertisement
Add Comment
Please, Sign In to add comment