473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Comparing hours in one single day

I got this problem for days or weeks now. I have to write a program using PHP5 and mysql 5.0.51b thats found on the WAMP 2.2
The dilemma is the following:
I have 5 meeting rooms each one named c1,c2,c3 etc
How do make a table where I can reserve a room at a certain date and certain time? This is the table i have so far:
Expand|Select|Wrap|Line Numbers
  1. Table name:centros
  2. name         type
  3. centroid =  datetime
  4. horainicio= datetime
  5. horafinal = datetime
  6. user      = varchar
  7. ultmod  = datetime
  8.  
This is my query that i do with mysql. Yet if I tell it that if there is a meeting room available between a certain reservation it will come out as true. For example C1 is reserved from 13:00:00 - 18:00:00. And if i do my query stating that horainicio= 14:00:00 it will not find it and say i can book the place. Please help me out I am going nuts.
Expand|Select|Wrap|Line Numbers
  1. $conn = connectDB();
  2.  
  3.  
  4.    $query = "select *
  5.            from centros 
  6.            where horainicio = '$horainicio' 
  7.               and centroid = '$centroid'";
  8.      $resultado = $conn->query($query);
  9.          if (!$resultado || $resultado->num_rows>0)
  10.           return false;
  11.  
  12.  
  13.    $query = "insert into centros
  14.                  values('',$centroid','$horainicio', '$horafinal','$status', '$lastmod', '$user'";
  15.  
  16.   $result = $conn->query($query);
  17.    if (!$result)
  18.      return false;
  19.    else
  20.      return true;
  21.  
Aug 1 '08 #1
1 1249
Atli
5,058 Expert 4TB
Hi, welcome to Bytes!

Have you tried the BETWEEN... AND satements?
For example:
Expand|Select|Wrap|Line Numbers
  1. SELECT COUNT(*) FROM myTable
  2. WHERE NOW() BETWEEN startDate AND endDate;
  3.  
P.S.
Naming your fields using non-english words is never a good idea. You never know who's going to be using your tables in the future. I for one can't really understand your query because I don't understand the field names.
Same goes for variables in you PHP code ;)
Aug 1 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

22
by: Bryan Guilliams | last post by:
I'm trying to come up with an elegant, simple way to compare two consecutive values from the same table. For instance: SELECT TOP 2 datavalues FROM myTable ORDER BY timestamp DESC That...
4
by: M.i.r.a.g.e. | last post by:
I am sorry if this has been asked before, but I looked all over for exactly what I need, before asking you guys. I know that it has something to do with the Date object, but I'm not sure how to...
41
by: Odd-R. | last post by:
I have to lists, A and B, that may, or may not be equal. If they are not identical, I want the output to be three new lists, X,Y and Z where X has all the elements that are in A, but not in B, and...
8
by: Riegnman | last post by:
Hey guys, I'm in need of a little help. I am very new to access but have been trying to learn. My problem is as follows. . . We have time clocks that dump the badge punches into a .log file on...
6
by: buildpc | last post by:
Hi, After 15 years, I left application development 4 years ago and have been working at home at something else. I've kept up my skills in VB6, VBA, MS Office and VSourceSafe. I had quite a bit...
19
by: Dennis | last post by:
I have a public variable in a class of type color declared as follows: public mycolor as color = color.Empty I want to check to see if the user has specified a color like; if mycolor =...
20
by: Bill Pursell | last post by:
This question involves code relying on mmap, and thus is not maximally portable. Undoubtedly, many will complain that my question is not topical... I have two pointers, the first of which is...
18
by: Carramba | last post by:
Hi! is there a better/faster way to compare mantissas of to real number then in following code? #include <stdio.h> #include <stdlib.h> int main(void) { float a,b; int test;
3
by: tcveltma | last post by:
Hi Everyone, I know there's been a lot of questions regarding the same kind of issue but I haven't been able to find an answer to my specific problem. Basically I have two tables, one table...
5
by: =?Utf-8?B?UElFQkFMRA==?= | last post by:
Not really a C#-specific comment, more general .net observations. 1) A while back I found the need to determine whether or not a particular StringComparer was case-insensitive. The best way I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.