Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $servername = "localhost";
- $username = "root";
- $pass = "pass";
- $dbName = "SheetPal";
- $conn = mysqli_connect($servername , $username , $pass , $dbName);
- $userID = $_SESSION["userID"];
- if(!$conn){
- die("Connection failed: " . mysqli_connect_error());
- }
- else{
- if(!$getWeek = $conn->prepare("SELECT date,task,paycode,starttime,finishtime,breaks,totalhours,comments FROM shifts WHERE userID = ? ORDER BY shiftID ASC")){
- echo "Getweek prepare failed: (" . $conn->error . ")";
- }
- else{
- if(!$getWeek->bind_param("s",$userID)){
- echo "Getweek bind parameter: " . $getWeek->error;
- }
- else{
- $getWeek->execute();
- if( !$getWeek->bind_result($date, $task, $paycode, $starttime, $finishtime, $breaks, $totalhours, $comments) ){
- echo "Getweek bind results failed: (" . $getWeek->errno . ") " . $getWeek->error;
- }
- else{
- $shift = array();
- while($getWeek->fetch()) {
- $shiftObject = (object) [
- "date" => $date,
- "task" => $task,
- "paycode" => $paycode,
- "starttime" => $starttime,
- "finishtime" => $finishtime,
- "breaks" => $breaks,
- "totalhours" => $totalhours,
- "comments" => $comments,
- ];
- array_push($shift,$shiftObject);
- }
- echo json_encode($shift);
- }
- }
- }
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement