Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <article class="article">
- <h2>Learning Corner</h2>
- <h2>Roster</h2>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $database = "forms";
- $days = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday');
- // Create connection
- $conn = new mysqli($servername, $username, $password, $database);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- //echo "Connected successfully ";
- $sql = "SELECT StaffID, S_StaffName FROM LC_Staff WHERE BranchID = '" . $_SESSION['branch'] . "'";
- $result = $conn->query($sql);
- ?>
- <table id="printTable" style="width:100%" border="1">
- <tr>
- <td width=100>Staff Name:</td>
- <?php
- for($i = 0; $i < sizeof($_POST['dates']); $i++) {
- $day = $days[$i];
- $date = $_POST['dates'][$i];
- ?>
- <td width=100><?php print("$day - $date"); ?></td>
- <?php
- }
- ?>
- </tr>
- <?php
- for ($i = 0; $i < sizeof($_POST['ids']); $i++) {
- ?>
- <tr>
- <?php
- $id = $_POST['ids'][$i];
- $name = $_POST['names'][$i];
- print "<input type='hidden' name='ids[]' value='$id'/><td>" . $name . "</td>";
- foreach ($days as $day) {
- ?>
- <?php
- $Times = $_POST[$day . 'Times'][$i];
- $NC = $_POST[$day . 'NonContact'][$i];
- $Leave = $_POST[$day . 'Leave'][$i];
- ?>
- <td style="padding: 0px">
- <input type="text" name="<?php print($day); ?>Times" value="<?php print($Times); ?>" disabled/>
- <input type="text" name="<?php print($day); ?>NonContact" value="<?php print($NC); ?>" disabled/>
- <input type="text" name="<?php print($day); ?>Leave" value="<?php print($Leave); ?>" disabled/>
- </td>
- <?php
- }
- ?>
- </tr>
- <?php
- }
- ?>
- </table>
- <br><br>
- <input type="submit" id="emailButton" class="two" value="Send Email"><br><br>
- <a class="two" href="Indexx.php">Home</a>
- <br><br>
- <script type="text/javascript">
- $("#emailButton").click(function() {
- var tableData = $("#printTable").prop('outerHTML');
- var result = post("RosterSendEmail.php", "data=" + tableData, false);
- console.log(result);
- });
- function post(url, data, isAsync) {
- var result = "undefined";
- $.ajax
- ({
- type: "POST",
- url: url,
- async: isAsync,
- data: data,
- success: function (data) {
- //Parse post url and data recieved back to handleResponse
- result = data;
- },
- error: function(xhr, textStatus, error){
- result = "failure";
- console.log(error);
- }
- });
- return result;
- }
- </script>
- </article>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement