Created
November 29, 2012 04:20
-
-
Save FoxRocks76/4166786 to your computer and use it in GitHub Desktop.
code for andho
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(isset($_POST['submit'])) | |
{ | |
if(isset($_POST['offdays'])) | |
{ | |
//$off is set through the config settings// | |
$shift = $_POST['shift']; | |
$from = $_POST['from']; | |
$to = $_POST['to']; | |
$emp_id = $_POST['emp_id']; | |
$sql = ("UPDATE schedule SET Shift_ID = '$shift' WHERE (`Date` BETWEEN '$from' AND '$to') AND (Emp_ID = '$emp_id')"); | |
if(!$result_shift_update_query = $mysqli->query($sql)) | |
{ | |
echo "INSERT ERROR 1 HERE"; | |
} | |
echo "Shift UPDATE SQL: " . $sql . "<br><br>";//error checking | |
$sql = ("SELECT `Date` FROM schedule WHERE (`Date` BETWEEN '$from' AND '$to') AND (Emp_ID = '$emp_id')"); | |
if(!$result_date_query = $mysqli->query($sql)) | |
{ | |
echo "INSERT ERROR 2 HERE"; | |
} | |
echo "SELECT SQL: " . $sql . "<br><br>";//error checking | |
while($row = $result_date_query->fetch_assoc()) | |
{ | |
echo "Date: " . $row['Date'] . "<br>";//error checking | |
$date = date('D',strtotime($row['Date'])); | |
if(in_array($date, $_POST['offdays'])) | |
{ | |
echo "MATCHED! Date: " . $date . "<br>";//error checking | |
$sql = ("UPDATE schedule SET Shift_ID = '$off' WHERE `Date` = '" . $row['Date'] . "' AND Emp_ID = '$emp_id'"); | |
if(!$result_update_offdays_query = $mysqli->query($sql)) | |
{ | |
echo "INSERT ERROR 3 HERE"; | |
} | |
echo "UPDATE DAYS OFF SQL: " . $sql . "<br><br>";//error checking | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment