dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: concert booking

  1. #1
    Join Date
    Apr 2007
    Posts
    4

    Unhappy concert booking

    I want to implement a concert booking system for my final year project

    basically, users can see what seats are available ... meanwhile the on screen seat will change its color in order to instantly let the other user notice the seat just being sold...

    is there anyone can help me figuring out what is the best approach for this project?

  2. #2
    Join Date
    Apr 2007
    Location
    Sunny Adelaide
    Posts
    13
    Hi,

    You can create a pseudo-persistent HTTP connection using the XMLHttpRequest object and a simple server-side script.
    See Comet

    Basically, you need to open a connection to the server once the page is loaded. In this server-side script you need to start a loop and query the bookings table for updates. If there are any updates, output your XML data representing these updates and flush the connection (by breaking out of the loop). If not, pause a bit (so as not to hang up the server's CPU) and then loop again.
    You should also consider whether your script has a maximum execution time in effect. For example, PHP has a default maximum execution time of 30 seconds. At this point, you should flush the connection and send some form of response which indicates no server-side activity (say, a null char).

    On the client side, you need to check the response to see if it is valid (contains update data in responseXML) or null; take the appropriate action and then re-open the connection as before.

    I can post some example code if necessary and if you tell me what server-side language you're using; but have a go first.

    Regards,

    - P
    Brevitywit

  3. #3
    Join Date
    Apr 2007
    Posts
    4

    reply

    Thanks for ur reply...
    i'm going to do it with PHP server side language
    just wonder how can i let the people click the to select the seat..

    does it mean every single seat i treat it as a submit button...
    once i click it it perform sql and update the database?!

    that would be great if u can send me some sample

  4. #4
    Join Date
    Apr 2007
    Location
    Sunny Adelaide
    Posts
    13
    If the 'live' display is a requirement, then you must make JavaScript a requirement. Which then means you can use AJAX for booking seats.

    I developed a live chat application using JavaScript and PHP. Have a look at the frontend and JavaScript code here:
    http://dev.penagate.com/ajax/livechat/

    I have also uploaded the PHP files as source code. The important one is this:
    poll.php
    This file is the one that is effects the pseudo-persistent connection. I have not commented the code because that is one of my great failings in life. However, the important part is the while() loop.
    $db->get_since($last) queries the database and returns all messages posted since the last message ID. If there are any then these are flushed back to the client.
    $wait_current counts up to 20 seconds so that PHP does not automatically kill the script and ruin everything.

    If you need any help at all understanding any of the code then please by all means post the relevant bits here and I will walk you through them. Overall this is a complete example of the pseudo-persistent connection technique I described.


    To submit seats just attach a click event handler to each element representing a seat. In this event handler, make a POST request to the server using an XMLHttpRequest object, passing the seat ID and customer ID and everything. You should also use sessions to authenticate user.


    Edit: Oh, and one other thing. That example will not work in IE, because it uses XHTML. If you use Firefox, I suggest you grab the Firebug extension, which will allow you to debug JavaScript.


    Regards,

    - P
    Last edited by Penagate; 04-26-2007 at 08:28 AM.
    Brevitywit

  5. #5
    Join Date
    Apr 2007
    Posts
    4

    reply

    How can i deal with concurrency problem?!

    like if two people wanna buy the same ticket at the same instantly time?!

Similar Threads

  1. Confused...Objects versus Datasets
    By Paul F in forum .NET
    Replies: 13
    Last Post: 03-22-2002, 07:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center