Hi
This is the first time I have really played with calendars in PHP and am a little, no, a lot stuck.
The MySQL database holds "job_id", "visit_date" which is a timestamp and also "engineer" which is one or more names seperated with :
My planner needs to have the dates in the left column, row by row, and the engieers names (pulled from another table) along the top row, column by column.
I have the date and names part working and can also tell if there is any work booked for that day, but what I cannot do, it work out how to put the job_id under the correct engineers name.
With the code below, I get 2 jobs showing on the 1st of the month which is correct, but how do I get the job under the correct engineers column?
Please be gentle:
<table>
<tr><td> </td><td> </td>
<?php
include ("includes/db.php");
$desired_month = 6;
$desired_year = "2012";
$num_days = date('t', mktime(0, 0, 0, $desired_month, 1, $desired_year));
$engarray = array();
$result = mysql_query("SELECT * FROM engineers ORDER BY name ASC");
while ($row=mysql_fetch_object($result)) {
$engarray[] = $row->name;
?>
<td><?php echo $row->name;?></td>
<?php
}
?>
</tr>
<?php
for ($index = 1; $index <= $num_days; $index++) {
$daysdate = mktime(0, 0, 0, date($desired_month) , date($index), date($desired_year));
$day = date('D', mktime(0, 0, 0, date($desired_month) , date($index), date($desired_year)));
?>
<tr><td><?php echo $day?></td><td><?php echo date('d M', $daysdate)?></td>
<td>
<?php
$jobs = mysql_query("SELECT * FROM job_details");
while ($rowjobs = mysql_fetch_object($jobs)) {
if ($rowjobs->visit_date == $daysdate) {
echo "job";
}
}
?>
</td>
</tr>
<?php
}
?>
</table>
I have an array with the engineers names in, but am just guessing now.
Thanks in advance for any help.