nezbo Posted June 4, 2008 Share Posted June 4, 2008 hi all i have a start time and an end time, using mktime, and i want to display them in a table. e.g. neil has 1 weeks holiday, steven has 2 days holiday and bob has 1 day holiday monday 1st Jan 2008neil Tuesday 2nd Jan 2008neil, steven ,bob Wednesday 3rd Jan 2008neil, steven Thursday 4thJan 2008neil Friday 5th Jan 2008neil Saturday 6th Jan 2008neil Sunday 7th Jan 2008neil Bellow is the code i have so far. I have come to a bit of a holt, i am not to sure where to go from here $nowTime = mktime(); $sql = "SELECT *, DATE_FORMAT(FROM_UNIXTIME(timeStampStart),'%W %b %Y') as newStime FROM dental_holidayrequest WHERE timeStampStart > '$nowTime' || timeStampEnd > '$nowTime' GROUP BY newStime ORDER BY timeStampStart"; $result = @mysql_query($sql) or die(@mysql_error()); ?> <table align="center" border="1"> <?php while($row = @mysql_fetch_array($result)) { echo "<tr><td><div style='font-size:18px'><strong>" . $row['newStime'] . "</strong></div></td><td>"; $getingStaff = "SELECT * FROM person WHERE grade = '" . $_GET['nameSelected'] . "' && CallID = '" . $row['staffMember'] . "'"; $theResults = @mysql_query($getingStaff) or die(@mysql_error()); while ($theResults2 = mysql_fetch_array($theResults)) { echo $theResults2['FullName']; } echo "</td></tr>"; } ?> </table> <?php this produces the fillowing with only the first day of the holiday and not the whole week. Sunday Jun 2008 Wednesday Jun 2008 Thursday Jun 2008 Friday Jun 2008 Monday Jun 2008 Joanne Pearce Tuesday Jun 2008 Tuesday Jul 2008 Wednesday Jul 2008 Friday Jul 2008 Monday Jul 2008 Thursday Jul 2008 Friday Aug 2008 Thursday Aug 2008 Monday Aug 2008 Wednesday Aug 2008 Yvonne Plant Tuesday Aug 2008 Monday Sep 2008 Tuesday Sep 2008 Friday Sep 2008 Thursday Sep 2008 Wednesday Sep 2008 Monday Oct 2008 Friday Oct 2008 Wednesday Oct 2008 Thursday Oct 2008 Monday Nov 2008 Tuesday Dec 2008 Joanne Pearce Wednesday Dec 2008 Monday Dec 2008 Joanne Pearce Friday Jan 2009 Joanne Pearce Monday Jan 2009 Tuesday Feb 2009 Any ideas ??? Link to comment https://forums.phpfreaks.com/topic/108675-date-sorting-help/ Share on other sites More sharing options...
nezbo Posted June 4, 2008 Author Share Posted June 4, 2008 So far i have this code the only problem is that it doesnt spread accross the amount of days that the holiday covers... $sql = "SELECT dental_holidayrequest.*, person.*, DATE_FORMAT(FROM_UNIXTIME(dental_holidayrequest.timeStampStart),'%W %D %b %Y') as newStime FROM person, dental_holidayrequest WHERE person.CallID = dental_holidayrequest.staffMember AND ((dental_holidayrequest.timeStampStart > '$nowTime' OR dental_holidayrequest.timeStampEnd > '$nowTime') AND person.grade = '" . $_GET['nameSelected'] . "') GROUP BY newStime ORDER BY dental_holidayrequest.timeStampStart"; $result = @mysql_query($sql) or die(@mysql_error()); ?> <table align="center" border="1"> <?php while($row = @mysql_fetch_array($result)) { echo "<tr><td><div style='font-size:18px'><strong>" . $row['newStime'] . "</strong></div></td><td>"; echo $row['FullName']; echo "</td></tr>"; } ?> </table> Link to comment https://forums.phpfreaks.com/topic/108675-date-sorting-help/#findComment-557371 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.