pls help.....how to?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
crazytopu
Forum Contributor
Posts: 259
Joined: Fri Nov 07, 2003 12:43 pm
Location: London, UK
Contact:

pls help.....how to?

Post by crazytopu »

hi guys,

running into a problem. hope somebody can help.


i want to reserve a book. but dat reservation will be activated only for 15 hours.

So, i gave the call_no from the form and it reserve the book under the member name who supplied that call_no and his ID.

i wrote a script that find out the 15 hours from the time when the reservation made and save that time in the reservation time along with the call_no.


but i am just not sure how to inactivate that reservation after 15 hours?


When i run a php script i know i can check the column value and i can easily make the reservation inactivated.

but in this case when i m not about to run any php script but still wnt to see the reservation gets inactivated after the stipulated time, i aint got a clue how to do this.


can anybody give me any tips, idea?

shoudl i use any mysql specific funciton?

pls help
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

All you need to do is everytime some one uses the script, check for inactive reservations and remove them. Leave the end time there and check it. Just make sure you do it the first thing - I.E. on the log in page at the top. This will ensure that it is *like* the reservations are removed at the appropriate time, because the user will never be able to know that there is an active expired reservation there. Also, you might want to do it on every page as well, in case one expires while the user is there.
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Post by liljester »

you could write a script that only checks for reservation times, and invalidates expired reservations, then set up a scheduled task (windows) or a cron job (linux/unix) to run the script every 5 minutes or so, however, magicrobotmonkey's suggestion would prolly work just as well =)
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

actually, i think mine would work better because a cron job every five minutes allows 4:59 of inaccurate data! A combination of the two would also work though.
crazytopu
Forum Contributor
Posts: 259
Joined: Fri Nov 07, 2003 12:43 pm
Location: London, UK
Contact:

Post by crazytopu »

Thank you all. I think i got the clue.. :)
Post Reply