noam76

read data from sql table

Jun 22nd, 2017
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.94 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  <html lang="he">
  3.  <?php $thisPage="DataIntegration" ?>
  4.  <head>
  5.  <meta charset="utf-8">
  6. <link rel="stylesheet" type="text/css" href="style.css"/>
  7.  <title>Scheduling_profs</title>
  8.  </head>
  9. <body>
  10.  <div id="wrapper">
  11. <div id="headerBar">
  12.     <?php include("menu.php"); ?> <!-- insert the menu -->
  13.   </div> <!-- #header -->
  14.  <div id="content">
  15.  <h2>הצגת נתונים</h2>
  16.  <div class="inner" align="right">
  17. <?php header('Content-Type: text/html; charset=utf-8');
  18.  
  19. echo "<table class='special' align='right';>";
  20.   echo "<tr>
  21.         <th>שם המתפלל</th>
  22.         <th>שם הפעולה</th>
  23.         <th>שם הפרשה</th>
  24.         <th>תאריך</th>
  25.         <th>סכום</th>
  26.         </tr>";
  27.  
  28. $customer_id = $_REQUEST['output'];
  29. $operation_id = $_REQUEST['output1'];
  30. $date = $_REQUEST['date'];
  31. $thora = $_REQUEST['thora'];
  32. $servername = "localhost";
  33. $username = "root";
  34. $password = "";
  35. $dbname = "synagogue";
  36.  
  37.  try
  38.  {
  39.      $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
  40.      // set character name
  41.     $conn->query("SET NAMES 'utf8'");
  42.  }
  43. catch(PDOException $e)
  44. {
  45.      echo "Error: " . $e->getMessage();
  46. }
  47.  
  48. /* echo $customer_id. "<br>";
  49. echo $operation_id. "<br>";
  50. echo $_REQUEST['btn_submit']. "<br>";
  51. echo $thora. "<br>"; */
  52.  
  53. switch ($_REQUEST['btn_submit'])
  54. {
  55. case "Button 1": // מתפלל
  56. if($customer_id == ""){}
  57. else
  58. {
  59. $sth = $conn->query("SELECT data_integration_table.date, data_integration_table.thora, data_integration_table.amount, customer_table.first_name, customer_table.last_name, operation_table.operation_name, sum(data_integration_table.amount) AS 'TotalAmount' FROM data_integration_table
  60.      INNER JOIN customer_table ON data_integration_table.customer_id = customer_table.customer_id
  61.      INNER JOIN operation_table ON data_integration_table.operation_id = operation_table.operation_id WHERE customer_table.customer_id = $customer_id");
  62.      
  63.      $sth->setFetchMode(PDO::FETCH_BOTH);// Mode par défaut (tableau)
  64.      while($row = $sth->fetch())
  65.     {
  66.      echo "</tr>";
  67.      echo "<td>", $row['first_name'], '&nbsp',  $row['last_name'],"</td>";
  68.      echo "<td>", $row['operation_name'], "</td>";
  69.      echo "<td>", $row['thora'], "</td>";
  70.      echo "<td>", $row['date'], "</td>";
  71.      echo "<td>", $row['amount'], '&#8362;', "</td>";
  72.      echo "</tr>";
  73.      $totalsum = $row['TotalAmount'];
  74.     }
  75.     $sth->closeCursor();
  76. }
  77. break;
  78.  
  79. case "Button 2": // פעולה
  80. if($operation_id == ""){}
  81. else
  82. {
  83. $sth = $conn->query("SELECT data_integration_table.date, data_integration_table.thora, data_integration_table.amount, customer_table.first_name, customer_table.last_name, operation_table.operation_name, sum(data_integration_table.amount) AS 'TotalAmount' FROM data_integration_table
  84.      INNER JOIN customer_table ON data_integration_table.customer_id = customer_table.customer_id
  85.      INNER JOIN operation_table ON data_integration_table.operation_id = operation_table.operation_id WHERE operation_table.operation_id = $operation_id");
  86.      
  87.      $sth->setFetchMode(PDO::FETCH_BOTH);// Mode par défaut (tableau)
  88.      while($row = $sth->fetch())
  89.     {
  90.      echo "</tr>";
  91.      echo "<td>", $row['first_name'], '&nbsp',  $row['last_name'],"</td>";
  92.      echo "<td>", $row['operation_name'], "</td>";
  93.      echo "<td>", $row['thora'], "</td>";
  94.      echo "<td>", $row['date'], "</td>";
  95.      echo "<td>", $row['amount'], '&#8362;', "</td>";
  96.      echo "</tr>";
  97.      $totalsum = $row['TotalAmount'];
  98.     }
  99.     $sth->closeCursor();
  100. }
  101. break;
  102.  
  103. case "Button 3": // תורה
  104. if ($thora == ""){} // check for empty box
  105. else
  106. {
  107. $sth = $conn->query("SELECT data_integration_table.date, data_integration_table.thora, data_integration_table.amount, customer_table.first_name, customer_table.last_name, operation_table.operation_name, sum(data_integration_table.amount) AS 'TotalAmount' FROM data_integration_table
  108.      INNER JOIN customer_table ON data_integration_table.customer_id = customer_table.customer_id
  109.      INNER JOIN operation_table ON data_integration_table.operation_id = operation_table.operation_id WHERE data_integration_table.thora = '$thora'");
  110.      
  111.      $sth->setFetchMode(PDO::FETCH_BOTH);// Mode par défaut (tableau)
  112.      while($row = $sth->fetch())
  113.     {
  114.      echo "</tr>";
  115.      echo "<td>", $row['first_name'], '&nbsp',  $row['last_name'],"</td>";
  116.      echo "<td>", $row['operation_name'], "</td>";
  117.      echo "<td>", $row['thora'], "</td>";
  118.      echo "<td>", $row['date'], "</td>";
  119.      echo "<td>", $row['amount'], '&#8362;', "</td>";
  120.      echo "</tr>";
  121.      $totalsum = $row['TotalAmount'];
  122.     }
  123.     $sth->closeCursor();
  124. }
  125. break;
  126.  
  127. case "Button 4": //הצג הכל
  128.     $sth = $conn->query("SELECT data_integration_table.date, data_integration_table.thora, data_integration_table.amount, customer_table.first_name, customer_table.last_name, operation_table.operation_name, sum(data_integration_table.amount) AS 'TotalAmount' FROM data_integration_table
  129.      INNER JOIN customer_table ON data_integration_table.customer_id = customer_table.customer_id
  130.      INNER JOIN operation_table ON data_integration_table.operation_id = operation_table.operation_id");
  131.    
  132.     $sth->setFetchMode(PDO::FETCH_BOTH);// Mode par défaut (tableau)
  133.      while($row = $sth->fetch())
  134.     {
  135.      echo "</tr>";
  136.      echo "<td>", $row['first_name'], '&nbsp',  $row['last_name'],"</td>";
  137.      echo "<td>", $row['operation_name'], "</td>";
  138.      echo "<td>", $row['thora'], "</td>";
  139.      echo "<td>", $row['date'], "</td>";
  140.      echo "<td>", $row['amount'], '&#8362;', "</td>";
  141.      echo "</tr>";
  142.      $totalsum = $row['TotalAmount'];
  143.     }
  144.    
  145.     // $totalsum = $row['TotalAmount'];
  146.     $sth->closeCursor();
  147. break;
  148.  
  149. } // Closw Switch
  150.  
  151. echo "</table>";
  152.  
  153. echo "<table>";
  154.   echo "<tr class='noborder'>
  155.         <td></td>
  156.         <td></td>
  157.         <td></td>
  158.         <th>סך הכל</th>
  159.         <th>", $totalsum, '&#8362;', "</th>
  160.         </tr>
  161.     </table>";
  162.      
  163. $conn = null;
  164.  
  165. ?>
  166.    </div><!-- #innner -->
  167.    </div><!-- #content -->
  168.   <!-- #footer -->
  169.   <footer>
  170.   <?php include("footer.php"); ?> <!-- insert the footer -->
  171.   </footer><!-- #footer -->
  172. </body>
  173.  </html>
Add Comment
Please, Sign In to add comment