Jump to content
xisto Community
Sign in to follow this  
Howlin1

Sorting By The Days Of The Week.

Recommended Posts

Hello,I am wondering is there any way to sort a list by the days of the week (i.e. it should list Monday, Tuesday, Wednesday, Thursday and Friday)?I am trying to make a kinda of timetable of free rooms in a building and list the weekdays (Monday - Friday), Floors (Ground, first and second) and then the time (9 am until 4pm, but I have that solved by using the 24 hour time).Ideally what I want is to call the free rooms table for all the days/time etc of rooms that are free, and sort that list by the day of the week and then sort that result by the floor (but keeping Monday first). What I have at the moment is:

$result= mysql_query( "SELECT * FROM free_rooms ORDER BY Day, Floor, Time ASC") or die("SELECT Error: ".mysql_error());        echo '<p>This is a list of all the rooms that are free and on what day.</p>	<table border="1" width="400">	<tr align="center">	<td><b>Day</b></td>	<td><b>Floor</b></td>	<td><b>Room</b></td>	<td><b>Time</b></td>	</tr>';	while ($get_info = mysql_fetch_row($result))	{        print '<tr align="center">	<td><b>' . $get_info[1] . '</b></td>	<td>' . $get_info[4] . '</td>	<td>' . $get_info[2] . '</td>	<td>' . $get_info[3] . ':15</td>	</tr>';		}	print '        </table>';	mysql_close($link);        ?>

(I'm assuming the get_info is a 2d array) So what I would need to do is to sort the get_info[1] array so Monday is first, Tuesday, Wednesday, Thursday and finally Friday. Then sort the floor (get_info[4]) by Ground, First and Second, while keeping Monday first.On the order by clause I did try putting in ('Monday') for the day, but it only brought one or two of the Mondays to the top. I don't know enough about php (I'm a novice really) to do what I would like to do.Is there anyway that what I want done, can be done (wholly or partially)?

post-122460-0-91660200-1313274466_thumb.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.