puntapuisomos Posted March 5, 2008 Share Posted March 5, 2008 I have made a system with which teachers can book class rooms. In the database the following data are stored: date, time & period, classroom, teacher code. When asked for a survey appears that lists the bookings as follows (with more data, but this is the basis): 2008-03-05: Room G15, period 1: 08.30, (MNA) Mike Nameful 2008-03-05: Room G15, period 3: 10.10, (KKN) Karl Knowbody I would, however, like the list also to include the periods that do not have any bookings: so actually my list would like this: 2008-03-05: Room G15, period 1: 08.30, (MNA) Mike Nameful 2008-03-05: Room G15, period 2: 09.20, <empty> 2008-03-05: Room G15, period 3: 10.10, (KKN) Karl Knowbody I have the following script (sorry for the Dutch words but I am sure you will get around with it...): <? $query1="select lokaal, week, datum, roosteruur, uur, reserveren.code, naam from reserveren,code,uren where reserveren.code=code.code AND reserveren.uur=uren.tijd AND week='$weeknr' AND jaar='$jaar' Order by lokaal, datum, uur"; $result1 = mysql_query ($query1); while (list ($lokaal, $week, $datum, $roosteruur, $uur, $code,$naam) = mysql_fetch_row($result1)){ echo "<TR><TD bgcolor=$color>$lokaal</TD><TD>$week</TD><TD bgcolor=$color_day>$dagnaam $datum2</TD><TD bgcolor=$color_day>$roosteruur</TD><TD>$uur</TD><TD>$code</TD><td>$naam</td></TR>"; } But does anyone know a solution to include the empty ones, without having to record them in the database itsself? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/94542-booking-schedule/ Share on other sites More sharing options...
sasa Posted March 5, 2008 Share Posted March 5, 2008 create table with all posible periods in one day (is it table uren?) and RIGHT JOIN it Quote Link to comment https://forums.phpfreaks.com/topic/94542-booking-schedule/#findComment-484164 Share on other sites More sharing options...
puntapuisomos Posted March 5, 2008 Author Share Posted March 5, 2008 Thanks a lot so far. You're right: it would be table "uren" (=Hours). And I see your point. However, I know what a join is but not a "right join" . Could you please explain this? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/94542-booking-schedule/#findComment-484244 Share on other sites More sharing options...
puntapuisomos Posted March 5, 2008 Author Share Posted March 5, 2008 Sorry, I have looked up the term "right join" and I think I can manage the right join myself now. Thanks a lot, the problem is solved I think! Quote Link to comment https://forums.phpfreaks.com/topic/94542-booking-schedule/#findComment-484254 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.