Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. <?php
  2.  
  3. mysql_connect('localhost','root','');
  4. mysql_select_db('accounts');
  5. $sql= "SELECT * FROM users1";
  6. $list=mysql_query($sql);
  7.  
  8. ?>
  9. <html>
  10. <head>
  11. <title>Welcome to ScanNShop</title>
  12. </head>
  13. <h1>Welcome to ScanNShop</h1>
  14.  
  15. <body>
  16.  
  17. <table width="600" border="1" cellpadding="1" cellspacing="1">
  18. <tr>
  19.  
  20. <th>No.</th>
  21. <th>Name</th>
  22. <th>Price</th>
  23. <tr>
  24.  
  25. <?php
  26.  
  27. while ($users1=mysql_fetch_assoc($list)) {
  28.  
  29. echo "<tr>";
  30.  
  31. echo "<td>".$users1['pid']."</td>";
  32.  
  33. echo "<td>".$users1['name']."</td>";
  34.  
  35. echo "<td>".$users1['price']."</td>";
  36.  
  37. }
  38.  
  39. ?>
  40.  
  41. </table>
  42. </body>
  43. </html >
  44.  
  45. No. Name Price
  46. 1 bread 2.00
  47. 2 milk 2.00
  48. 3 janabab 6797994.00
  49. 4 jajajsh 846494.00
  50.  
  51. mysql_connect('localhost','root','');
  52. mysql_select_db('accounts');
  53. $sql= ('SELECT * FROM users1');
  54. $list=mysql_query($sql);
  55.  
  56. ?>
  57. <html>
  58. <head>
  59. <title>Welcome to ScanNShop</title>
  60. </head>
  61. <h1>Welcome to ScanNShop</h1>
  62.  
  63. <body>
  64.  
  65. <table width="600" border="1" cellpadding="1" cellspacing="1">
  66. <tr>
  67. <th>No.</th>
  68. <th>Name</th>
  69. <th>Price</th>
  70. </tr>
  71.  
  72. <?php
  73. $total=0;
  74. while ($users1=mysql_fetch_assoc($list)) {
  75.  
  76. echo "<tr>";
  77.  
  78. echo "<td>".$users1['pid']."</td>";
  79.  
  80. echo "<td>".$users1['name']."</td>";
  81.  
  82. echo "<td>".$users1['price']."</td>";
  83.  
  84. $total = $users1['price']+$total;
  85.  
  86. echo "</tr>";
  87.  
  88. }
  89. echo '<tr><td></td><td>Total:</td><td>'.$total.'</td></tr>';
  90.  
  91. ?>
  92.  
  93. </table>
  94. </body>
  95. </html >
  96.  
  97. $sum = 0;
  98. while ($users1=mysql_fetch_assoc($list)) {
  99. $sum += $users1['price'];
  100.  
  101. echo '<tr>';
  102. echo '<td>'.$users1['pid'].'</td>';
  103. echo '<td>'.$users1['name'].'</td>';
  104. echo '<td>'.$users1['price'].'</td>';
  105. echo '</tr>';
  106. }
  107.  
  108. echo '<tr>';
  109. echo '<td></td>';
  110. echo '<td>Total</td>';
  111. echo '<td>'.$sum.'</td>';
  112. echo '<tr>';
  113.  
  114. SELECT Number, Min(Name) AS Name, SUM(amount) AS Price
  115. FROM grocery_list
  116. GROUP BY Number WITH ROLLUP
  117.  
  118. Number Name Price
  119. 1 bread 2.00
  120. 2 milk 2.00
  121. 3 janabab 6797994.00
  122. 4 jajajsh 846494.00
  123. NULL bread 7644492.00
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement