Skip to content

Instantly share code, notes, and snippets.

@andho
Forked from FoxRocks76/updated code
Created November 29, 2012 05:32
Show Gist options
  • Save andho/4167013 to your computer and use it in GitHub Desktop.
Save andho/4167013 to your computer and use it in GitHub Desktop.
code for andho
<?php
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
foreach ($_POST['offdays'] as $offday)
{
$sql = ("UPDATE schedule SET Shift_ID = '$off' WHERE (`Date` BETWEEN '$from' AND '$to') AND (Emp_ID = '$emp_id') AND (DATE_FORMAT(`Date`, '%a') = '$offday')");
if (false !=== ($result_update_offdays_query = $mysqli->query($sql)))
{
echo "UPDATE DAYS OFF SQL: " . $sql . "<br><br>";//error checking
} else {
echo "INSERT ERROR 3 HERE";
}
}
$mysqli->commit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment