keymasterviriya1150

Untitled

May 5th, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.24 KB | None | 0 0
  1. <html>
  2.     <head><meta charset="UTF-8">
  3.     <title>รายการที่สั่ง</title>
  4.  
  5.     <link rel="stylesheet" href="css/productdemoo.css">
  6.     </head>
  7.  
  8.     <br><br><br><br>
  9.     <div align="center">
  10.     <body>
  11. <h1><font face="AgaraDull">รายการสินค้าทีี่สั่งซื้อ</font></h1>
  12. <br>
  13. <?php
  14.     //หัวข้อตาราง
  15.     echo"<form action='send.php' method='post'>";
  16.    
  17.     $con=mysqli_connect("localhost","root","","testorder");
  18.     /*if($con!=null)
  19.         echo"Sucess";*/
  20.     $result=mysqli_query($con,"SELECT * FROM list" );
  21.     if(!$result)
  22.         die("connot");
  23.    
  24.     $p=0;
  25.     $c;
  26.     echo "<table border=1>";
  27.     while($row=mysqli_fetch_array($result,MYSQLI_NUM))
  28.     {
  29.        
  30.         for($i=0; $i< 4 ;$i++)
  31.         {
  32.             $c[$p][$i]=$row[$i];
  33.         }
  34.  
  35.         $p++;
  36.     }
  37.     /*for($i=0; $i< 6 ;$i++)
  38.     {
  39.         echo "<tr>";
  40.         for($j=0; $j< 4 ;$j++)
  41.         {
  42.             echo "<td>".$c[$i][$j]."</td></br>";
  43.         }
  44.         echo "</tr>";
  45.     }*/
  46.  
  47.     $data=array("ลำดับ","รหัสรายการ","ประเภท","ราคา","จำนวน","ราคารวม"    );
  48.     echo"<table border=0>";
  49.         echo"<tr bgcolor=#ffcc00>";
  50.             for($i=0; $i<count($data) ; $i++)
  51.                 echo"<td>".$data[$i]."</td>";  
  52.     echo"</tr>";
  53.    
  54.  
  55.     // =========================================================================
  56.         $cheak=array(0,0,0,0,0,0); // เชคการแสดงข้อความ
  57.     // =========================================================================
  58.  
  59.     echo"<tr bgcolor=#ffffff>";
  60.             echo"<td>".$c[0][0]."</td>";   
  61.             echo"<td>".$c[0][1]."</td>";   
  62.             echo"<td>".$c[0][2]."</td>";   
  63.             echo"<td>".$c[0][3]."</td>";   
  64.  
  65.             $tmp=0;
  66.             if($_POST['user_pass1']>0)
  67.             {
  68.                 $cheak[0]=1;
  69.                 echo"<td>".$_POST['user_pass1']."</td>";
  70.                 echo"<input type=hidden value=". $_POST['user_pass1'] ." name=at[0]>";
  71.             }
  72.  
  73.             else
  74.                 echo"<td>0</td>";  
  75.            
  76.             if($cheak[0]==1)
  77.                 echo"<input type=hidden value=0 name=gg[0]>";
  78.             else if($cheak[0]==0)
  79.                 echo"<input type=hidden value='-1' name=gg[0]>";
  80.            
  81.                
  82.             $result1=$_POST['user_pass1']*35;
  83.             echo"<input type=hidden value=". $result1 ." name=total[0]>";
  84.             echo"<input type=hidden value='001' name=IDType[0]>";
  85.             echo"<input type=hidden value='freshmilk' name= 0]'>";
  86.             echo"<input type=hidden value=". '35'." name='price[0]'>";
  87.             echo"<td>".$result1."</td>";   
  88.     echo"</tr>";
  89.  
  90.     echo"<tr bgcolor=#ffff99>";
  91.             echo"<td>".$c[1][0]."</td>";   
  92.             echo"<td>".$c[1][1]."</td>";   
  93.             echo"<td>".$c[1][2]."</td>";   
  94.             echo"<td>".$c[1][3]."</td>";   
  95.             $tmp=0;
  96.             if($_POST['user_pass2']>0)
  97.             {
  98.                     $cheak[1]=1;
  99.                     echo"<td>".$_POST['user_pass2']."</td>";
  100.                     echo"<input type=hidden value=".$_POST['user_pass2']." name=at[1]>";               
  101.             }  
  102.             else
  103.                 echo"<td>0</td>";
  104.             if($cheak[1]==1)
  105.                 echo"<input type=hidden value=1 name=gg[1]>";
  106.             else if($cheak[1]==0)
  107.                 echo"<input type=hidden value='-1' name=gg[1]>";           
  108.            
  109.                    
  110.  
  111.             $result2=$_POST['user_pass2']*40;
  112.             echo"<input type=hidden value=". $result2 ." name=total[1]>";
  113.             echo"<input type=hidden value='002' name='IDType[1]'>";
  114.             echo"<input type=hidden value='greentea' name='Type[1]'>";
  115.             echo"<input type=hidden value=". '40'." name='price[1]'>";
  116.             echo"<td>".$result2."</td>";   
  117.     echo"</tr>";
  118.  
  119.     echo"<tr bgcolor=#ffffff>";
  120.             echo"<td>".$c[2][0]."</td>";   
  121.             echo"<td>".$c[2][1]."</td>";   
  122.             echo"<td>".$c[2][2]."</td>";   
  123.             echo"<td>".$c[2][3]."</td>";   
  124.        
  125.             if($_POST['user_pass3']>0)
  126.             {
  127.                 $cheak[2]=1;
  128.                 echo"<td>".$_POST['user_pass3']."</td>";   
  129.                 echo"<input type=hidden value=". $_POST['user_pass3'] ." name=at[2]>";
  130.             }  
  131.             else
  132.                 echo"<td>0</td>";  
  133.             if($cheak[2]==1)
  134.                 echo"<input type=hidden value=2 name=gg[2]>";
  135.             else if($cheak[2]==0)
  136.                 echo"<input type=hidden value='-1' name=gg[2]>";
  137.            
  138.  
  139.             $result3=$_POST['user_pass3']*40;
  140.             echo"<input type=hidden value=". $result3 ." name=total[2]>";
  141.             echo"<input type=hidden value='003' name='IDType[2]'>";
  142.             echo"<input type=hidden value='pink milk' name='Type[2]'>";
  143.             echo"<input type=hidden value=". '40'." name='price[2]'>";
  144.             echo"<td>".$result3."</td>";   
  145.     echo"</tr>";
  146.  
  147.     echo"<tr bgcolor=#ffff99>";
  148.             echo"<td>".$c[3][0]."</td>";   
  149.             echo"<td>".$c[3][1]."</td>";   
  150.             echo"<td>".$c[3][2]."</td>";   
  151.             echo"<td>".$c[3][3]."</td>";   
  152.            
  153.             if($_POST['user_pass4']>0)
  154.             {  
  155.                 $cheak[3]=1;
  156.                 echo"<td>".$_POST['user_pass4']."</td>";   
  157.                 echo"<input type=hidden value=". $_POST['user_pass4'] ." name=at[3]>";
  158.             }
  159.             else
  160.                 echo"<td>0</td>";
  161.             if($cheak[3]==1)
  162.                 echo"<input type=hidden value=3 name=gg[3]>";
  163.             else if($cheak[3]==0)
  164.                 echo"<input type=hidden value='-1' name=gg[3]>";           
  165.            
  166.            
  167.             $result4=$_POST['user_pass4']*35;
  168.             echo"<input type=hidden value=". $result4 ." name=total[3]>";
  169.             echo"<input type=hidden value='004' name='IDType[3]'>";
  170.             echo"<input type=hidden value='Iced tea' name='Type[3]'>";
  171.             echo"<input type=hidden value=". '35'." name='price[3]'>";
  172.             echo"<td>".$result4."</td>";   
  173.     echo"</tr>";
  174.  
  175.     echo"<tr bgcolor=#ffffff>";
  176.             echo"<td>".$c[4][0]."</td>";   
  177.             echo"<td>".$c[4][1]."</td>";   
  178.             echo"<td>".$c[4][2]."</td>";   
  179.             echo"<td>".$c[4][3]."</td>";   
  180.             $tmp=0;
  181.             if($_POST['user_pass5']>0)
  182.             {
  183.                 $cheak[4]=1;
  184.                 echo"<td>".$_POST['user_pass5']."</td>";   
  185.                 echo"<input type=hidden value=". $_POST['user_pass5'] ." name=at[4]>";
  186.        
  187.             }  
  188.             else
  189.                 echo"<td>0</td>";
  190.             if($cheak[4]==1)
  191.                 echo"<input type=hidden value=4 name=gg[4]>";
  192.             else if($cheak[4]==0)
  193.                 echo"<input type=hidden value='-1' name=gg[4]>";
  194.            
  195.             $result5=$_POST['user_pass5']*35;
  196.             echo"<input type=hidden value=". $result5 ." name=total[4]>";
  197.             echo"<input type=hidden value='005' name='IDType[4]'>";
  198.             echo"<input type=hidden value='Ovaltine' name='Type[4]'>";
  199.             echo"<input type=hidden value=". '35'." name='price[4]'>";
  200.             echo"<td>".$result5."</td>";   
  201.     echo"</tr>";
  202.  
  203.     echo"<tr bgcolor=#ffff99>";
  204.             echo"<td>".$c[5][0]."</td>";   
  205.             echo"<td>".$c[5][1]."</td>";   
  206.             echo"<td>".$c[5][2]."</td>";   
  207.             echo"<td>".$c[5][3]."</td>";       
  208.             $tmp=0;
  209.             if($_POST['user_pass6']>0)
  210.             {
  211.                 $cheak[5]=1;
  212.                 echo"<td>".$_POST['user_pass6']."</td>";   
  213.                 echo"<input type=hidden value=". $_POST['user_pass6'] ." name=at[5]>";
  214.                 echo"<input type=hidden value=". $cheak[5] ." name=c[5]>";
  215.                
  216.             }
  217.             else
  218.                 echo"<td>0</td>";
  219.             if($cheak[5]==1)
  220.                 echo"<input type=hidden value=5 name=gg[5]>";
  221.             else if($cheak[5]==0)
  222.                 echo"<input type=hidden value='-1' name=gg[5]>";
  223.            
  224.    
  225.             $result6=$_POST['user_pass6']*35;
  226.             echo"<input type=hidden value=". $result6 ." name=total[5]>";
  227.             echo"<input type=hidden value='006' name='IDType[5]'>";
  228.             echo"<input type=hidden value='cocoa' name='Type[5]'>";
  229.             echo"<input type=hidden value=". '35'." name='price[5]'>";
  230.             echo"<td>".$result6 ."</td>";  
  231.  
  232.            
  233.     echo"</tr>";
  234.     echo"</table>";
  235.  
  236.  
  237.     echo "<br/  ><br/>";
  238.     echo"<input type='submit' value='ยืนยัน'> &nbsp;";
  239.     echo "<br/>";
  240.     echo"<br/><input  type='button'  onClick='window.history.back()' value='ย้อนกลับ'>";
  241.  
  242.  
  243.    
  244.     echo"</form>";
  245.     $Type=array("นมสด","ชาเขียว","ชานมชมพู","ชาเย็น","โอวัลติน","โกโก้");
  246.     $sumAll=null;
  247.     for($j=0; $j< 6; $j++)
  248.     {
  249.         if($cheak[$j]==1   && $j==0)
  250.         {
  251.             echo"คุณสั่งซื้อ ".$Type[$j]. "  ราคา  35 บาท เป็นจำนวน ".$_POST['user_pass1']."  แก้ว     ทั้งหมดราคา ".$result1 ." บาท<br/>" ; 
  252.             $sumAll=$sumAll+$result1;
  253.         }
  254.         if($cheak[$j]==1 &&  $j==1)
  255.         {
  256.             echo"คุณสั่งซื้อ ".$Type[$j]. "  ราคา  40 บาท เป็นจำนวน ".$_POST['user_pass2']."  แก้ว    ทั้งหมดราคา ".$result2 ." บาท<br/>" ;
  257.             $sumAll=$sumAll+$result2;
  258.         }
  259.         if($cheak[$j]==1 &&  $j==2)
  260.         {
  261.             echo"คุณสั่งซื้อ ".$Type[$j]. "  ราคา  40บาท เป็นจำนวน ".$_POST['user_pass3']."  แก้ว    ทั้งหมดราคา ".$result3 ." บาท<br/>" ;
  262.             $sumAll=$sumAll+$result3;
  263.         }
  264.         if($cheak[$j]==1 &&  $j==3)
  265.         {
  266.             echo"คุณสั่งซื้อ ".$Type[$j]. "  ราคา  35 บาท เป็นจำนวน ".$_POST['user_pass4']."  แก้ว   ทั้งหมดราคา ".$result4 ." บาท<br/>" ;
  267.             $sumAll=$sumAll+$result4;
  268.         }
  269.         if($cheak[$j]==1 &&  $j==4)
  270.         {
  271.             echo"คุณสั่งซื้อ ".$Type[$j]. "  ราคา  35 บาท เป็นจำนวน ".$_POST['user_pass5']."  แก้ว   ทั้งหมดราคา ".$result5 ." บาท<br/>" ;   
  272.             $sumAll=$sumAll+$result5;
  273.         }
  274.         if($cheak[$j]==1 &&  $j==5)
  275.         {
  276.             echo"คุณสั่งซื้อ ".$Type[$j]. "  ราคา  35 บาท เป็นจำนวน ".$_POST['user_pass6']."  แก้ว   ทั้งหมดราคา ".$result6 ." บาท<br/>" ;
  277.             $sumAll=$sumAll+$result6;
  278.         }
  279.        
  280.     }
  281.     if($sumAll==0)
  282.         echo "คุณยังไม่ได้สั่งสินค้า<br/>";
  283.     else
  284.         echo "รวมทั้งสิ้นเป็นเงิน ".$sumAll."บาท <br/>";
  285.    
  286.  
  287.    
  288.    
  289.  
  290.  
  291. ?>
  292.  
  293.     </body>
  294. </html>
  295.  
  296. <body bgcolor="#33cc99">
Advertisement
Add Comment
Please, Sign In to add comment