Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help Plz Anyone

    Hi i need a bit of help

    i am creating a hotel reservation system using php and mysql. one of the criteria of the system is to prevent double booking taking place for example if 2 users book only one room which is availbele, then only one person should be allowed to get that.

    i dont know if u am right in using a lock function please some one tell me how to use that to control concurrency

  • #2
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Have a room_number and booked table in the MySQL database. The room_number table would hold all the room numbers, and the booked table could hold some booking information when the form is submitted.

    Your webpage would run a query and display only the rows that have no information in the booked table. So if room 234 is booked it doesn't show up, if the reservation is cancelled then the booked table becomes empty and will then display the room as being available.
    Leonard Whistler

  • #3
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    Please post helpful thread titles. if everyone posted such titles, the forum would be useless as to figure out what threads were about what.

    to answer your question see the link in my signature.

  • #4
    New Coder
    Join Date
    Jul 2005
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It depend on your database structure basically you could use like that
    PHP Code:
    LOCK TABLES trans READcustomer WRITE;
    select sum(valuefrom trans where customer_idsome_id;
    update customer set total_value=sum_from_previous_statement
               where customer_id
    =some_id;
    UNLOCK TABLES
    If you can not find a decision, maybe you have to try to change a problem

    http://www.gunman.co.nr
    http://bglinux.org

  • #5
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    Quote Originally Posted by gunman View Post
    It depend on your database structure basically you could use like that
    PHP Code:
    LOCK TABLES trans READcustomer WRITE;
    select sum(valuefrom trans where customer_idsome_id;
    update customer set total_value=sum_from_previous_statement
               where customer_id
    =some_id;
    UNLOCK TABLES
    Have you posted in the right thread? This doesn't seem to answer the OPs question.

  • #6
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Quote Originally Posted by guelphdad View Post
    to answer your question see the link in my signature.
    The link in your signature has been a real life saver for the past couple of weeks. I wouldn't be surprised if it answered 50% of the questions posted in this forum. Well done on the links Guelphdad.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •