I have a php query which i have attached. This display a shift pattern for the user who has logged in within a html table. This is working well and has forward and back buttons for day, week and month.
[php]<?php
$INQID = $fgmembersite->userID();
$loc = $fgmembersite->UserLocation();
$PattRef = $fgmembersite->UserShift_ref();
$FwdBck = $_POST[“FwdBck”];
if ($FwdBck =="")
{
$FwdBck = 86400;
}
$start = time();
$range_start = $start - $FwdBck;
$range_end = $range_start + 2419200;
$username = “******”;
$password = “******”;
$hostname = “******”;
$dbhandle = mysql_connect($hostname, $username, $password)
or die(“Unable to connect to MySQL”);
$selected = mysql_select_db(“databasename”,$dbhandle)
or die(“Could not select databasename”);
$result = mysql_query(“SELECT Date_Unix, $PattRef FROM Shift_Pattern WHERE Date_Unix >$range_start and Date_Unix <$range_end”);
$result_array = array();
$i=1;
while($row = mysql_fetch_array($result))
{
$result_array[$i] = $row[$PattRef];
$i++;
$result_array[$i] = $row[‘Date_Unix’];
$i++;
$d = $row[‘Date_unix’];
}
for ($x = 1; $x < $i; $x=$x+2) {
switch ($result_array[$x]){
case “1”:
$table_Field[1] = “#FFFFFF”;
$table_Field[3] = “1”;
break;
case “2”:
$table_Field[1] = “#FFFF99”;
$table_Field[3] = “2”;
break;
case “3”:
$table_Field[1] = “#99CCFF”;
$table_Field[3] = “3”;
break;
case “4”:
$table_Field[1] = “#CC33FF”;
$table_Field[3] = “4”;
break;
case"5":
$table_Field[1] = “#66FF99”;
$table_Field[3] = “5”;
break;
case"6":
$table_Field[1] = “#FFCCFF”;
$table_Field[3] = “6”;
break;
case"7":
$table_Field[1] = “#CCCCCC”;
$table_Field[3] = “7”;
break;
case"8":
$table_Field[1] = “#FFCC66”;
$table_Field[3] = “8”;
break;
case"9":
$table_Field[1] = “#FF0066”;
$table_Field[3] = “9”;
break;
case"10";
$table_Field[1] = “#FFCC99”;
$table_Field[3] = “10”;
break;
case “11”:
$table_Field[1] = “#FFFF99”;
$table_Field[3] = “11”;
break;
case “12”:
$table_Field[1] = “#99CCFF”;
$table_Field[3] = “12”;
break;
case “13”:
$table_Field[1] = “#CC33FF”;
$table_Field[3] = “13”;
break;
case"14":
$table_Field[1] = “#66FF99”;
$table_Field[3] = “14”;
}
$table_Field[2] = date(“l”, $result_array[$x+1])."
";
$table_Field[2] = $table_Field[2] . date(“j/m/Y”, $result_array[$x+1])."
";
if($x==15||$x==29||$x==43) echo"
?>
<td bgcolor=<?= $table_Field[1] ?> align=center><?= $table_Field[2] ?>
<?= $table_Field[3] ?>
I then have a additional table with three columns user_id, date and status, this is any variance in a users shift pattern, I need to add this to the table if the date and the user match at the correct date.
All dates are in unix time as the shifts are 24 hours a day i find it easier.
This is the part i am struggling with, i can get a echo of the date and status but i can’t get it in the correct place within the table. any help would be appreciated. Thank you in advance
forgive my code if messy i’m fairy new to php.