Advertisement
Guest User

code

a guest
Sep 4th, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. <article class="article">
  2. <h2>Learning Corner</h2>
  3. <h2>Roster</h2>
  4.  
  5. <?php
  6. $servername = "localhost";
  7. $username = "root";
  8. $password = "";
  9. $database = "forms";
  10. $days = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday');
  11.  
  12. // Create connection
  13. $conn = new mysqli($servername, $username, $password, $database);
  14.  
  15. // Check connection
  16. if ($conn->connect_error) {
  17. die("Connection failed: " . $conn->connect_error);
  18. }
  19. //echo "Connected successfully ";
  20.  
  21.  
  22. $sql = "SELECT StaffID, S_StaffName FROM LC_Staff WHERE BranchID = '" . $_SESSION['branch'] . "'";
  23.  
  24.  
  25. $result = $conn->query($sql);
  26.  
  27.  
  28. ?>
  29.  
  30. <table id="printTable" style="width:100%" border="1">
  31. <tr>
  32. <td width=100>Staff Name:</td>
  33. <?php
  34. for($i = 0; $i < sizeof($_POST['dates']); $i++) {
  35. $day = $days[$i];
  36. $date = $_POST['dates'][$i];
  37. ?>
  38. <td width=100><?php print("$day - $date"); ?></td>
  39. <?php
  40. }
  41. ?>
  42. </tr>
  43.  
  44. <?php
  45. for ($i = 0; $i < sizeof($_POST['ids']); $i++) {
  46. ?>
  47. <tr>
  48.  
  49. <?php
  50. $id = $_POST['ids'][$i];
  51. $name = $_POST['names'][$i];
  52. print "<input type='hidden' name='ids[]' value='$id'/><td>" . $name . "</td>";
  53.  
  54. foreach ($days as $day) {
  55.  
  56. ?>
  57.  
  58. <?php
  59.  
  60. $Times = $_POST[$day . 'Times'][$i];
  61. $NC = $_POST[$day . 'NonContact'][$i];
  62. $Leave = $_POST[$day . 'Leave'][$i];
  63.  
  64.  
  65. ?>
  66.  
  67. <td style="padding: 0px">
  68. <input type="text" name="<?php print($day); ?>Times" value="<?php print($Times); ?>" disabled/>
  69. <input type="text" name="<?php print($day); ?>NonContact" value="<?php print($NC); ?>" disabled/>
  70. <input type="text" name="<?php print($day); ?>Leave" value="<?php print($Leave); ?>" disabled/>
  71. </td>
  72.  
  73.  
  74. <?php
  75. }
  76. ?>
  77. </tr>
  78.  
  79. <?php
  80. }
  81. ?>
  82. </table>
  83. <br><br>
  84. <input type="submit" id="emailButton" class="two" value="Send Email"><br><br>
  85. <a class="two" href="Indexx.php">Home</a>
  86. <br><br>
  87.  
  88. <script type="text/javascript">
  89. $("#emailButton").click(function() {
  90.  
  91. var tableData = $("#printTable").prop('outerHTML');
  92.  
  93. var result = post("RosterSendEmail.php", "data=" + tableData, false);
  94.  
  95. console.log(result);
  96.  
  97.  
  98. });
  99.  
  100. function post(url, data, isAsync) {
  101. var result = "undefined";
  102.  
  103. $.ajax
  104. ({
  105. type: "POST",
  106. url: url,
  107. async: isAsync,
  108. data: data,
  109.  
  110. success: function (data) {
  111. //Parse post url and data recieved back to handleResponse
  112. result = data;
  113. },
  114.  
  115. error: function(xhr, textStatus, error){
  116. result = "failure";
  117. console.log(error);
  118. }
  119. });
  120.  
  121. return result;
  122. }
  123. </script>
  124. </article>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement