Jump to content

php and mysql time query


nezbo

Recommended Posts

Hi all

 

I have a problem with an ORDER BY in my select statment.

 

The proble i have is the if i order by time asc i get the 10:00 befor 9:00 and 00:00 before everthing and it should read

 

09:00 first shift of the day.

10:00

00:00 last sift of the day.

 

Hope this makes sence.

 

Neil

Link to comment
Share on other sites

sorry i have noticed a error in my code eeek.

 

but i still need the 00:00 to be displayed last. is this posible.

 

This is my code.

 

{
$todaysDate = date('Y-m-d');
$getDatesFromRota = mysql_query("SELECT * FROM _fullrota WHERE fourWeekDate = '$todaysDate' ORDER BY fullStartTime") or die(mysql_error());
?>
<table align="center" border="1"><tr class="1"><td colspan="3"><strong><h3>Todays Staff Are!</h3></strong></td></tr>
<tr class="2"><td><strong>Staff Name</strong></td><td><strong>Location</strong></td><td><strong>Start Time</strong></td></tr>
<?php
while ($getDatesFromRota2 = mysql_fetch_array($getDatesFromRota))
{
	if (($getDatesFromRota2['atcStaff']) == 0)
	{
		$theShiftPerson = $getDatesFromRota2['fullStaffName'];
	}
	else
	{
		$theShiftPerson = $getDatesFromRota2['atcStaff'];
	}

	$person = mysql_query("SELECT * FROM person WHERE CallID = $theShiftPerson") or die(mysql_error()); 
	while ($person2 = mysql_fetch_array($person))
	{
		$Person = $person2['FullName'];
	}
	$duty = mysql_query("SELECT * FROM  _duty WHERE dutyID = '$getDatesFromRota2[fullDuty]'") or die(mysql_error()); 
	while ($duty2 = mysql_fetch_array($duty))
	{
		$duty3 = $duty2['dutyName'];
	}

	echo "<tr onmouseover=this.style.backgroundColor='#ebf5fc' onmouseout=this.style.backgroundColor='#FFFFFF'><td align=left>" . $Person . "</td><td>" . $duty3 . "</td><td>" . $getDatesFromRota2['fullStartTime'] . "</td></tr>";
}
?>
</table>
<?php
}

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.