Note that there are some explanatory texts on larger screens.

plurals
  1. POmysql data from calendar check if booked
    primarykey
    data
    text
    <p>I have a database with reservations for items. All reservations have an: ID , item ID, personWhoBookedId, time_from (unixtime) , time-to(unixtime).</p> <p>I like to display a day per day time schedual from hour to hour, and colour the timethat an item is booked and display the personWhoBookedID on that timeframe.</p> <p>like: </p> <pre><code>room1: 5:00 - 6:00: free 6:00 - 7:00: booked by[person] 8:00 - 9:00:free </code></pre> <p>and</p> <pre><code>room 2: 5:00 - 6:00: free 6:00 - 7:00: booked by[person] 8:00 - 9:00: booked by[person] </code></pre> <p>etc</p> <p>At this time I iterate through the existing items with mysql, then check per timeframe with mysql if there is a booking that equals itemID and timeis between the mentioned timeframe of time-from and time-to</p> <p>This works but is does a lot of queries on the database.</p> <p>To increase performance I think I better frist get all the reservations and store them in a multi dimensional array, like this:</p> <pre><code> $allreservationsperday = mysql_query("select id, personid, itemid, time_from, time_to FROM reservations where time_from &gt;= '$unixfrom' and time_to &lt; '$unixto'"); while($reservationarray = mysql_fetch_array($allreservationsperday)){ $res[$reservationarray ["id"]]["personid"] = $reserveringenarray["personid"]; $res[$reservationarray ["id"]]["itemid"] = $reserveringenarray["itemid"]; $res[$reservationarray ["id"]]["time_from"] = $reserveringenarray["time_from"]; $res[$reservationarray ["id"]]["time_to"] = $reserveringenarray["time_to"]; } </code></pre> <p>and then display the timeline by a for Loop to loop through the hours of the day But I cannot figure out how to check per hour if there is a reservation in the just formed array.</p> <p>Any help most welcome! jeroen</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload