Im trying to compare an entered value in a drop down box to see if an asset is available for use.
At the moment its is
From -
Duration -
Could i be better with
From -
To-
Which would be easier to implement.
Ive attached what i have so far.
Im trying to compare an entered value in a drop down box to see if an asset is available for use.
At the moment its is
From -
Duration -
Could i be better with
From -
To-
Which would be easier to implement.
Ive attached what i have so far.
Against my better judgement I downloaded this zip, but I fail to see what's going on. When index.php is run, only a blank dropdown ("area") appears.
Perhaps you need to post your code here for everybody to see.
And perhaps provide a link to any threads relating to this in the past.
Ill make a mental note of that . Im still not sure how to populate duration. As in to use an array or not.
<!DOCTYPE HTML>
<html>
<head>
<title>Multiple Select Boxes</title>
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#loader').hide();
$('#area').change(function(){
$('#building').fadeOut();
$('#loader').show();
$.post("ajax/get_building.php", {
area: $('#area').val()
}, function(response){
setTimeout("finishAjax('building', '"+escape(response)+"')", 400);
});
return false;
});
$('#building').change(function(){
$('#model').fadeOut();
$('#loader').show();
$.post("ajax/get_model.php", {
area: $('#area').val(),
building: $('#building').val()
}, function(response){
setTimeout("finishAjax('model', '"+escape(response)+"')", 400);
});
return false;
});
});
function finishAjax(id, response){
$('#loader').hide();
$('#'+id).html(unescape(response));
$('#'+id).fadeIn();
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Room Finder</title>
<link type="text/css" rel="stylesheet" href="main.css">
</head>
<body>
<header class="body">
</header>
<section class="body">
<div id="loader"><strong>Loading...</strong></div>
<form name="form" id="form" method="POST" form action="<?php echo $_SERVER['PHP_SELF']; ?>" >
<div class="styled-select">
<label>Area:</label>
<select id="area" name="area">
<option value="">-- Select Area--</option>
<?php
include('lib/class_dbcon.php');
$connect = new Connect();
$q = mysql_query("SELECT * FROM area ORDER BY area_id ASC");
while($row = mysql_fetch_assoc($q))
{
echo '<option value="'.$row['area_id'].'">'.$row['area'].'</option>';
}
$connect->disc();
?>
</select>
<label for="building">Building:</label>
<select id="building" name="building">
<option value="">-- Select Building --</option>
</select>
<label for="from">From:</label>
<select id="from" name="from">
<option value="">-- Choose Time --</option>
</select>
<label for="duration">Duration:</label>
<select id="duration" name="durarion">
<option value="">-- Choose Duration --</option>
</select>
<label for="search">Search:</label>
<input id="search" type="search" />
<label for="filter">Search Filter:</label>
<select name="filter1">
<option value="">Select Filter</option>
<option value="Software">software</option>
<option value="Room">Room</option>
</select>
</div>
<input id="submit" name="submit" type="submit" value="Submit">
</form>
</section>
<section class="body">
</section>
<footer class="body">
</footer>
</body>
</html>
Basically all i need to do is somehow compare values from the Time and Duration to the TimeTable table i set up.
tt_id
room_id (FK)
day (int)
start (int)
end (int)this will have to be 24 for endtime - which technically doesn't exist)
1. Are you working on a weekly timetable or cyclic (e.g. fortnightly)?
I have some recollection of going down this path before and advising that it would be a BLIND attempt. You really need a visual timetable for this.
I would suggest a tabs type interface, one tab for each room (or even dropdown or option buttons - whatever and a fixed timetable grid for the week. Start of Week in a dropdown.
SO you then have:
TIME | MON | TUE | (etc)
08:00 [+] DFG
08:30 DRT [+]
09:00 HUI/3 Me![-]
(etc)
Where you have [+] representing a 'make booking' and [-] representing one of your booking that you can remove, thereby freeing up the session in that room.
Here's a screenshot of a system (OLD!) I made for my school:
It shows a series of rooms for a certain date with the periods running down the side. Some lessons are timetabled (dark). I've booked myself in (red), with a 'clear' link below my initials. All other free periods are now blocked for 5 minutes, to avoid block booking. Once the time is up, I can book again (green) via clickable links.
That's not a 'look at me, ain't I great', but just an idea for a simple visual interface. I can't help feeling that a 'click and hope for the best' scenario will end up with the user throwing his/her laptop out of the window. :)
I am working with a weekly time table.
I went with the tabs because i also needed to filter as to what software the rooms had. But manly to i could paginate the results due to the fact there are thousands of rooms.
And the fact i have no idea how to go down the other route.
I suppose i could use that system then display the timetable system you suggested.
What im trying to achieve is sort of.
Room - (room number)
Day Monday - Tuesday - Wednesday - Thursday - Friday
Times
09:00 Games design
10:00 Games design
11:00 Scripting
12:00 Php dev
13:00
List of software in room
Number of pcs in use
OK, once you get the DB system sorted, it should be easy:
buildings
building_id
building_label
(optional fields like lat/long for google maps etc if you need to show this)
rooms
room_id
room_label
building_id
no_pcs
software
software_id
software_label
software_version
(optional fields for manufacturer etc or tags for advanced search)
room_software
room_software_id (optional, but may be useful for joins)
room_id
software_id
(you could have an optional no_pcs here if not all pcs in the room have the same software on them)
periods (timetabled)
period_id
weekday (1->5 in your case or ENUM type)
start_time
end_time (or an easier approach would be a period_no instead of times if periods are set in stone)
course_id
room_id
(optional like user_id for teacher etc)
courses
course_id
course_label
course_code
course_start
course_end (these fields only impt if courses duration not the same as full academic year)
course_admin (FK user_id)
If you allow ad-hoc bookings of free periods by staff:
bookings
book_id
user_id
the_date (no need to place weekday)
period_no OR start_time/end_time
time_booked (datestamp - useful for logging use or to prevent users from making hundreds of bookings one after the other)
Obviously you'd have other tables, like users, possibly course_users.
I strongly suggest trying to force the period_no instead of start_times/end_times, however, you could have a period_times table with this data.
With a fixed grid (days/periods), you can use the same html template to map timetabled periods showing the user (you) what's available in which room at the click of a button/tab.
ALso, your search criteria will be flexible, e.g. you can search for 'Dreamweaver' for at least 10 pcs 'sometime' on Monday.
Hope it helps.
I have set that up where do i go from here with the grid?
Use a loop for creating a html table:
DAY across top
PERIOD down side
So you have this basic html:
<table>
<thead>
<tr>
<th>PERIOD</th>
<th>MONDAY</th>
<th>TUESDAY</th>
<th>WEDNESDAY</th>
<th>THURSDAY</th>
<th>FRIDAY</th>
</tr>
</thead>
<tbody>
Then you build the table importing timetabled lessons as you go using a nested loop:
//this assumes you've placed all lessons for this room into an array called $timetable - can be done easily via loop from DB
$output = "";
for($period=1;$period<7;$period++){
$output .= "<tr><th>$period</th>";
for($days=1;$days<6;$days++){
$input = (isset($timetable[$day][$period])) ? $timetable[$day][$period] : "<a href=\"...booking parameters...\">BOOK ME</a>";
$output .= "<td>$input</td>";
}
$output .= "</tr>";
}
$output .= "</body></table>";
That give you enough to go on?
EDIT
//JUST thought the fact that we're using integers for the loop counters and array keys - perhaps this will cause a problem. As array are option base 0 (not option base 1). Anyway give it a whirl. This is off the top of my head - so it hasn't been tested or even code/completed, so there are probably errors.
What would i do if i wanted to take the lessons from a database , due to the large about of lessons.
Due to the fact that each course has alot of different topics
You filter with a WHERE clause. Based on room_id if that's the way you want to display it.
'SELECT * FROM periods ...INNER JOINS...WHERE room_id = $room_id'
while($row = ...){
$timetable[$row['day']][$row['period']] = array('class' => $row['class'], 'teacher' => $row['teacher']...);
}
... as code in previous post...
$output = "";
for($period=1;$period<7;$period++){
$output .= "<tr><th>$period</th>";
for($days=1;$days<6;$days++){
$input = (isset($timetable[$day][$period])) ? $timetable[$day][$period] : "<a href=\"...booking parameters...\">BOOK ME</a>";
$output .= "<td>$input</td>";
}
$output .= "</tr>";
}
$output .= "</body></table>";
As I mentioned earlier, the only major thing that might cause problems is the 'Option Base 0' for arrays. If so, you can prefix keys like so:
while($row = ...){
$timetable['d_' . $row['day']]['p_' . $row['period']] = array('class' => $row['class'], 'teacher' => $row['teacher']...);
}
... as code in previous post...
$output = "";
for($period=1;$period<7;$period++){
$output .= "<tr><th>$period</th>";
for($days=1;$days<6;$days++){
$input = (isset($timetable['d_' . $day]['p_' . $period])) ? $timetable['t_' . $day]['p_' . $period] : "<a href=\"...booking parameters...\">BOOK ME</a>";
$output .= "<td>$input</td>";
}
$output .= "</tr>";
}
$output .= "</body></table>";
I still think my old way may have been better due t massive amounts of tabs or large drop downs , i dont see how i could check what rooms are available now on the fly.
Ill try to explain better i know im doing a terrible job.
Say im sat down i need to find another room to go to how would i implement that into a graphical interface. If i picked say building a i would be sifting through for ages till i found one.
This is a room view! Now that your data is normalized, you can throw in any type of view you like.
E.g. pseudocode
SEARCH FORM
software checkboxes (or multiselect dropdown)
datepicker
period (or period times)
minimim PCs
rooms checkboxes (or multiselect dropdown)
/SEARCH FORM
You get the data from the form ($_POST) and build a WHERE clause:
if(isset($_POST['rooms'])){
$raw_rooms = (array)$_POST['rooms'];
$where['rooms'] = 'room_id IN (' . implode(',',array_map('intval',$raw_rooms)) . ')';
}
if(isset($_POST['datepicker'])){
//check it is a date with preg_match or similar
$unixdate = strtotime($_POST['datepicker']);
$where['day'] = '`day` = ' . date('w',$unixdate);
//$where['dated'] = '`bookdate` = date('Y-m-d', $unixdate); this may need some work
}
if(isset($_POST['period']) && is_int($_POST['period']) && $_POST['period'] > 0 && $_POST['period'] < 7){
//e.g. for a 6 period day
$where['period'] = '`period` = ' . $_POST['period'];
}
if(isset($_POST['min_pc']) && is_int($_POST['min_pc']) && $_POST['min_pc'] > 0){
$where['min_pc'] = 'pc_no = ' . $_POST['min_pc'];
}
if(isset($_POST['sw'])){
$raw_sw = (array)$_POST['sw'];
$where['software'] = '`software_id` IN (' . implode(',',array_map('intval',$raw_sw)) . ')';
}
$sqlwhere = (isset($where)) ? implode(', ',$where) : '';
$sql = 'SELECT * FROM timetable ' . $where;
That'll return any free rooms that match your needs.
Aaaah ok cheers i think that should sort it thank a lot ardav.
Oops mistake iast line sould be
$sqlwhere not $where
if(isset($_POST['rooms'])){
$raw_rooms = (array)$_POST['rooms'];
$where['rooms'] = 'room_id IN (' . implode(',',array_map('intval',$raw_rooms)) . ')';
}
Just to pick this apart.
if the room i want is set , send the imploded array , the room_id in $rawrooms intval and stores it in $where.
Your form contains (I suggest either checkboxes or multiselect dropdown) and send on the data stored in $_POST.
The (array) forces the $raw_rooms to be an array even if it only has one value.
The $where variable is an array of field-value pairs.
The $where array is imploded into a clause.
The 'rooms' is probably the least useful field as you're probably just looking for an available room with the set conditions (software/min pcs etc). However, if you want to refine the search to a number of rooms you know, then it may be useful.
Is me doing it like this making it easier? I appreciate your patience.
<!DOCTYPE HTML>
<html>
<head>
<title>Multiple Select Boxes</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Room Finder</title>
<link type="text/css" rel="stylesheet" href="main.css">
</head>
<body>
<header class="body">
</header>
<section class="body">
<form name="form" value="form" method="POST" form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<div class="styled-select">
<label>Area:</label>
<select value="area" name="area">
<option value="">-- Select Area--</option>
<option value="area1" >area1</option>
</select>
<p>
</br>
<label for="building">Building:</label>
<select value="building" name="building">
<option value="">-- Select Building --</option>
<option value="1" name ="building1">1</option>
<option value="2" name ="building2">2</option>
<option value="3" name ="building3">3</option>
<option value="4" name ="building4">4</option>
</select>
</br>
<p>
<label for="slot">Time Slot:</br></label>
<select value ="slot" name="slot[]" multiple="multiple">
<option value="1" >8-9</option>
<option value="2" >9-10</option>
<option value="3" >10-11</option>
<option value="4" >11-12</option>
<option value="5" >12-13</option>
<option value="6" >13-14</option>
<option value="7" >14-15</option>
<option value="8" >15-16</option>
<option value="9" >16-17</option>
<option value="10" >17-18</option>
<option value="11" >18-19</option>
<option value="12" >19-20</option>
<option value="13" >20-21</option>
</select>
<p>
</br>
<label for="search">Search:</label>
<input value="search" type="search" />
</br>
<p>
<label for="filter">Search Filter:</label>
<select name="filter">
<option value="">Select Filter</option>
<option value="Software">software</option>
<option value="Room">Room</option>
</select>
</div>
</P>
<input type="submit" value="Send" />
</form>
</section>
<section class="body">
<?php
$test=$_POST['slot'];
if ($test){
foreach ($test as $t){echo 'You selected ',$t,'<br />';}
}
?>
</section>
<footer class="body">
</footer>
</body>
</html>
I think you're over-egging it with the search filter, but up to you. What about software search (dropdown - multiselect)?
This form may be restrictive. If you play with the idea I suggested, you'll get a far more flexible form.
MULTISELECT ROOMS (CAN OPTGROUP THEM INTO BUILDINGS) -can be left blank for ALL
MULTISELECT SOFTWARE - can be left blank for ALL
MIN_NO PCS
MULTISELECT SLOT (PERIOD) - as you've done.
You may wish to include a day or date though, otherwise you'll get every available slot in the week - not that useful if you can only use it on Wednesday.
I can see where you're coming from with the opt group
But I can see this casing problems , I had a search box so you don't have to scroll through massive amounts of rooms
very helpful information you have given above so thank you for sharing it here
very helpful information you have given above so thank you for sharing it here and must keep it up for more
Well, no big deal with the multiselect rooms, all that is, is a filter so you don't return every single room with a pc in it! Seriously, a search box will be fine - BUT - how will the user know which rooms exist? And they will have to match your entries in the DB to filter the result. That could be tricky.
I was thinking along the lines of a search where room_num using MATCH AGAINST
Of course that's fine - as long as you have an idea of the room number in the first place. The thing with the MATCH AGAINST is ok, but a bit tricky.
Your table should be MyISAM
Your room_label field should be FULLTEXT indexed which means it needs to be char/text-based not number
//EDIT
forgot to mention - if the search term is 3 chars or less, it'll be ignored (no returns)
if the term is found in >50% records in boolean mode, ditto
I was playing with this layout
<html>
<body>
<h4>Two rows and three columns:</h4>
<table border="1">
<tr><th>Day</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr><th>MonDay</th>
<td >english</td>
<td >science</td>
<td>-</td>
<td >english</td>
</tr>
<tr><th>TuesDay</th>
<td >maths</td>
<td >-</td>
<td>science</td>
<td >geography</td>
</tr>
<tr><th>WednesDay</th>
<td >english</td>
<td >science</td>
<td>-</td>
<td >english</td>
</tr>
<tr><th>ThursDay</th>
<td >maths</td>
<td >-</td>
<td>science</td>
<td >geography</td>
</tr>
<tr><th>FriDay</th>
<td >english</td>
<td >science</td>
<td>-</td>
<td >english</td>
</tr>
</table>
</body>
</html>
Its sort of the opposite of what you had so would the results be echo' down and ordered by day?
OK, it's a different layout, but the basics are the same - get all matching periods for that particular room - place them in an array, e.g. $array[$day][$period]... then just have nested loops for creating the table cells and checking for the existence of an array item. I think I gave an example of that in an earlier post.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.