Rachel Posted February 22, 2011 Share Posted February 22, 2011 Is there anyway to arrange an array like: Monday 12.00 14.00 16.00 Tuesday 12.00 14.00 16.00 etc instead of Monday 12.00 Monday 14.00 Monday 16.00 Tuesday 12.00 Tuesday 14.00 Tuesday 16.00 etc $sql4 = "select * from time_list where loc_id = $location_id and film_id = $film_id order by day asc"; $result4=mysql_query($sql4); while($rows4=mysql_fetch_array($result4)){ $time_id = $rows4['time_id']; <?php echo $rows4['day']; ?></td> <td><a href ="seating.php?cine=<?php echo $location_id; ?>&film=<?php echo $film_id; ?>&time=<?php echo $time_id; ?>"><?php echo $rows4['time']; }?> Thank you Quote Link to comment Share on other sites More sharing options...
shlumph Posted February 22, 2011 Share Posted February 22, 2011 I believe you'll have to implement your own function to organize the array like that, after getting the data from MySQL. Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted February 22, 2011 Share Posted February 22, 2011 You don't rearrange the array, you just need to check when to echo the day: $day = ''; while($rows4 = mysql_fetch_array($result4)) { if($day != $rows4['day']) { echo $rows4['day']; $day = $rows4['day']; } echo $rows4['time_id']; } Quote Link to comment Share on other sites More sharing options...
Rachel Posted February 22, 2011 Author Share Posted February 22, 2011 Big thanks, that woked how I wanted it to, but is there any way to order by time as the times are out of order? eg. friday 14.00 16.00 12.00 monday 14.00 12.00 16.00 saturday 16.00 14.00 12.00 sunday 14.00 16.00 12.00 thursday 14.00 12.00 16.00 tuesday 14.00 16.00 12.00 wednesday 12.00 16.00 14.00 Thankyou. Quote Link to comment Share on other sites More sharing options...
shlumph Posted February 22, 2011 Share Posted February 22, 2011 What's the name of the column? You'll want to order it with your MySQL query, just like you ordered the day. order by day asc, time asc Quote Link to comment Share on other sites More sharing options...
Rachel Posted February 22, 2011 Author Share Posted February 22, 2011 cool that works great. i didnt realise that i could order by twice. thanks for help guys Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.