Jump to content

farad

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Everything posted by farad

  1. farad

    Time query help

    Hey That is awesome I personally help quite abit on the Malware side and troubleshooting on other forums, but we can always develop our skills into others areas. I truly understand what you mean, as the majority of problem you encounter are primarily real-world based situations and thus you know the rest ... I will the points on board . If you don't mind I might add you on facebook, however if you use your facebook primarily for faimly etc. then I understand.
  2. farad

    Time query help

    Hey again. I will try that. Thanks alot. I am keen on learning more about databases (even though I do hardware support) and I find that the key to succeeding in anything and fully grasping any core subject is to understand the fundamentals of it, or shall I say the concept. You seem to know the logic behind every structure and although I do break things down into manageable steps which is a common methodology used in troubleshooting key components of any machine, and cancelling out devices one by one. I wanted if you could recommend a book, because, obviously your knowledge is superior and thus will predominantly specify the best book. Like I said, I will start using this forum more often. It was not a necessity to work, and even if for some strange reason it does not function, I still appreciate the effort. PS: off topic, you a cricket fan thanks
  3. farad

    Time query help

    There can be several bookings for a room in one day, that is how I want to design it. array(22) { [0]=> string(5) "121aa" ["Module_ID_"]=> string(5) "121aa" [1]=> string(50) "Level 1 Adventures in Criminology: Intro and Scope" ["Module_Title_"]=> string(50) "Level 1 Adventures in Criminology: Intro and Scope" [2]=> string(1) "1" ["Year_"]=> string(1) "1" [3]=> string(10) "Semester 1" ["Semester_"]=> string(10) "Semester 1" [4]=> string(2) "15" ["Credits_"]=> string(2) "15" [5]=> string(6) "Monday" ["Day_"]=> string(6) "Monday" [6]=> string( "13:00:00" ["Start_Time_"]=> string( "13:00:00" [7]=> string( "14:00:00" ["End_Time_"]=> string( "14:00:00" [8]=> string(3) "121" ["Tutor_"]=> string(3) "121" [9]=> string(6) "UCP005" ["Room_"]=> string(6) "UCP005" [10]=> string(0) "" ["Notes_"]=> string(0) "" } array(22) { [0]=> string(3) "211" ["Module_ID_"]=> string(3) "211" [1]=> string(30) "Level 1 Western Civilisation 1" ["Module_Title_"]=> string(30) "Level 1 Western Civilisation 1" [2]=> string(1) "1" ["Year_"]=> string(1) "1" [3]=> string(10) "Semester 1" ["Semester_"]=> string(10) "Semester 1" [4]=> string(2) "15" ["Credits_"]=> string(2) "15" [5]=> string(6) "Monday" ["Day_"]=> string(6) "Monday" [6]=> string( "09:00:00" ["Start_Time_"]=> string( "09:00:00" [7]=> string( "17:00:00" ["End_Time_"]=> string( "17:00:00" [8]=> string(3) "121" ["Tutor_"]=> string(3) "121" [9]=> string(6) "UCP005" ["Room_"]=> string(6) "UCP005" [10]=> string(0) "" ["Notes_"]=> string(0) "" } Using query Select * from tModule where Semester_ = 'Semester 1' AND Day_ ='Monday' AND Room_ ='UCP005'AND (End_Time_ <= '15:00:00' OR '16:00:00' <= Start_Time_) array(22) { [0]=> string(5) "121aa" ["Module_ID_"]=> string(5) "121aa" [1]=> string(50) "Level 1 Adventures in Criminology: Intro and Scope" ["Module_Title_"]=> string(50) "Level 1 Adventures in Criminology: Intro and Scope" [2]=> string(1) "1" ["Year_"]=> string(1) "1" [3]=> string(10) "Semester 1" ["Semester_"]=> string(10) "Semester 1" [4]=> string(2) "15" ["Credits_"]=> string(2) "15" [5]=> string(6) "Monday" ["Day_"]=> string(6) "Monday" [6]=> string( "13:00:00" ["Start_Time_"]=> string( "13:00:00" [7]=> string( "14:00:00" ["End_Time_"]=> string( "14:00:00" [8]=> string(3) "121" ["Tutor_"]=> string(3) "121" [9]=> string(6) "UCP005" ["Room_"]=> string(6) "UCP005" [10]=> string(0) "" ["Notes_"]=> string(0) "" }
  4. farad

    Time query help

    Hi, thanks, for taking your previous time, answering my questions. I tried that code as well, weirdly enogh it allows double booking. If you for example book: A: 09 - 17 then B: 13 - 14 (Allows this ) I thought perhaps if I pasted some more codes of mine, then maybe we can demistify it, or perhaps maybe not. The query used to create the table, this is only one table taken from the database, as the time stamps are stored here. mysql_query("Create table tModule ( Module_ID_ VARCHAR(100) NOT NULL, Module_Title_ VARCHAR(150) NOT NULL, Year_ INT(100) NOT NULL, Semester_ VARCHAR(30) NOT NULL, Credits_ INT(10) NOT NULL, Day_ VARCHAR(20) NOT NULL, Start_Time_ TIME NOT NULL, End_Time_ TIME NOT NULL, Tutor_ VARCHAR(20) NOT NULL, Room_ VARCHAR(50) NOT NULL, Notes_ VARCHAR(200), PRIMARY KEY (Module_ID_) ); "); The above definitely works as I can check the table in phpmyadmin. $sql =" Select * from tModule where Semester_ = '$Semester' AND Day_ ='$Day' AND Room_ ='$Room' AND (End_Time_ <= '$Start_Time' OR '$End_Time' <= Start_Time_)"; $result = mysql_query($sql, $odbc) or die ("<h2>Can't run query11</h2>"); f(mysql_num_rows($result)==0) { $sql ="INSERT INTO tModule (Module_ID_, Module_Title_,Year_, Semester_, Credits_, Day_, Start_Time_, End_Time_, Tutor_, Room_, Notes_) VALUES ('$Module_ID', '$Module_Title', '$Year', '$Semester', '$Credits', '$Day', '$Start_Time', '$End_Time', '$Tutor', '$Room', '$Notes')"; //This check if anything is returned from the previous query, if so, then it will not insert, but if nothing is returned meaning that time slot is not taking, the data is added.
  5. farad

    Time query help

    Hi I though I had it working but after several testings. There are some flaws in it This the original code I used and modified based on the requirement. $sql =" Select * from tModule where Semester_ = '$Semester' AND Day_ ='$Day' AND Room_ ='$Room' AND (End_Time_<='$End_Time' OR '$End_Time' <= Start_Time_) "; Now the above code works when I test certain times. I generally input 13:00 - 14:00. Now if I input 13:00 - 14:00 again it will block it, as it is a double booking. If I put 12:00 14:00 it will block it which is good. However if the first booking is 09:00 - 17:00 then I make a booking of 13:00 - 14:00 it will allow it. The above block certain double bookings but not all I also tried your suggestion $sql =" Select * from tModule where Semester_ = '$Semester' AND Day_ ='$Day' AND Room_ ='$Room' AND (End_Time_ <= '$Start_Time' OR '$End_Time' <= Start_Time_) The biggest problem I am having is if a room is already booked for 09 - 17 and you do 13 - 14 it allows it. This can get a little frustrating. I hope someone can help
  6. farad

    Time query help

    Hi I will give that a try. Thank you for your kindness it is much appreciated and your thorough explanation. I can understand alot of individuals may come to this forum to find that elusive answer and then banish never to be seen. Hopefully as my knowledge developed I will contribute something back to this forum.
  7. farad

    Time query help

    I did have a read did not want to be rude and I will read it again and again so I understand the concept. It just went over my head the first time. I can understand that the concept will be the same even though we are working with time stamps and dates have some similar attributed. I think I will give it another shot, if not then just stick to what I have. thanks.
  8. Hi there. I am having issues trying to perform a query which needs to check if a room is already booked. I created a a thread regarding this particular issue in this website but the suggested code did not work. I modified the code and tried several other methods, but the problem still persists. I can prevent a double booking. So for example if a room if booked for 11:00 to 12:00 and if you book the same time again for the particular room it will not work, i.e. stop data being inserted into the database. Now the issue arises when you book a room for 10:00 to 12:00 when that room is already booked for 11:00 12:00. I have tried to find the dusplicate time in the middle but hasn't helped. The weird thing is it stops the majority of double booking but not every signle entry I use. Here is the code below: $sql =" Select * from tModule where Semester_ = '$Semester' AND Day_ ='$Day' AND Room_ ='$Room' AND Start_Time_ >= '$Start_Time' AND Start_Time_<='$End_Time' AND End_Time_ >= '$Start_Time' AND End_Time_ <= '$End_Time' ";
  9. Hello there, thank you very much for your input. Quite rude of me not to reply any sooner though have been busy. Your suggestion was taken on board though I went for a slight modification, although it functions not fully. Instead of using the first method I went for using the sql numrows function. $odbc = mysql_connect('localhost','root','') or die ("Can't connect to server"); mysql_select_db('tTime', $odbc) or die ("Database does not exist"); $sql ="select * from tModule where Semester_ = '$Semester' AND Day_ ='$Day' AND Start_Time_ ='$Start_Time' AND Room_ ='$Room' "; $result = mysql_query($sql, $odbc) or die ("Can't run query"); if(mysql_num_rows($result)==0) { Run the insert code } if(mysql_num_rows($result)!=0) { Error out room is booked } That works perfectly fine and I have been testing it, not sure if that is the proper of way of doing it though. The problem comes if there is a time between, i.e. if a room is booked from 9:00:00 11:00:00 amd prevent and bookings from 08:00:00 to 10:00:00 I would appreciate any inputs on that. Thanks
  10. Hi guys Thanks for the reply. I will have a play around with what is suggested. field for time is defined as Time I am allowing the user to input the time loke so. 11:00:00.
  11. I have a problem which is why I am here. What I am trying to achieve I am creating a very very basic timetabling system online, using php and sql. I am still in the process of completing it and changing bits from here to there. Although I am fully aware that the current design / implementation needs several changes and amendments, but however it performs most of the basic functionalities from a login system to the ability to add data delete data and also reset the database and recreate. The problem I have a table called tCourse althouogh a full ERD implementation has not taken place, it is still trial and error period. The table consists of the following: - Course - Unit - Course_Code - Year (i.e. Yr1, Yr2, Yr3) - Credits (Value of the unit) - Day - Semester - Start_Time - End_Time - Room - Tutor At the moment the primary keys for the table are: - Day - Start_Time - Room_ - Semester This basically prevents a particular day, a semester, a room having been booked at the same time. Which for a very basic one is ok. The only problem is though, if someone books for example: Monday >> 13:00:00 To 14:00:00 >> 205 >> Sem1 (ok) Monday >> 13:00:00 To 14:00:00 >> 205 >> Sem1 (Not ok, which is good, as it is a repeat and prevents double booking) However the problem comes here: Monday >> 12:00:00 To 14:00:00 >> 205 >> Sem1 (ok) So this is allowing a booking even though that room will be busy i.e. booked between 13:00 to 14:00 So is there a way I can limit it, so if there is a room booked for that particular period it will not do it. I have done a bit of research and friend's have suggested doind several for loops and quering the database beforehand. I came here, mainly because there are a lot of experienced individuals here whom may have a simpler solution, although I can understand it won't be a one liner . I would appreciate any help, if not, it is still ok.
  12. I fixed the problem by putting the code outside my php. So it works.
  13. By the way I am trying to validate a drop down box, i.e. combobox.
  14. Hello there. Well this problem maybe basic but is kind of annoying me. I havea solution to it which I wil lexplain. I have created a .php document which has html codes as well. It is a form that provides validation, for arguments sake lets say it is a form that validates if a user has entered their username and password, if not it will produce an error. The problem I am having is I have embedded the code inside the echo " code is here "; Now I have looked at escape characters and tried afew things, yet it still produces the same error on the same line. Example echo " !!!!!!!<form action='book.php' method='post' onsubmit="return checkForm('flogin');">!!!!!! The reset of the form is here ..... ""; echo The area highlighted in exclamation marks is where the area occurs, due to the quotes. Any suggestions. Thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.