LLapsus Posted October 14, 2011 Share Posted October 14, 2011 Hello, I am quite new in PHP. I am doing a page with list of events (seminars). The events are saved in a XML file in chronological order and their each event has its date in d-m-Y format and time in h:m format. What I need to do is find the next event (with respect to the actual date and time). I can do it using a loop (foreach) and stringtotime() and comparing obtained values. However, this seems to be quite a clumsy way. Is there any better way to do it? Maybe there is a function, package or some extension, which I don't know... I tried xpath, however it does not know how to compare the dates (I use xml 1.0). Thank you very much. Quote Link to comment https://forums.phpfreaks.com/topic/249139-searching-for-next-event-in-a-list/ Share on other sites More sharing options...
jcbones Posted October 14, 2011 Share Posted October 14, 2011 The problem here is the xml file. If it were a database, you would have date functions to help you pull only the valid info. Being that it is xml, I don't know of a way for you to check dates, other than looping the data, until you find the one that you want. Quote Link to comment https://forums.phpfreaks.com/topic/249139-searching-for-next-event-in-a-list/#findComment-1279430 Share on other sites More sharing options...
LLapsus Posted October 14, 2011 Author Share Posted October 14, 2011 OK, thanks. I have never worked with a database, but I can have a try. Can you suggest what kind of database I can use? Quote Link to comment https://forums.phpfreaks.com/topic/249139-searching-for-next-event-in-a-list/#findComment-1279432 Share on other sites More sharing options...
jcbones Posted October 14, 2011 Share Posted October 14, 2011 The most common for small to medium sites, is MySQL. Which is also my suggestion. Most Linux hosts have this database installed. MySQL PHP functions PHP Object MySQL Tutorial Quote Link to comment https://forums.phpfreaks.com/topic/249139-searching-for-next-event-in-a-list/#findComment-1279435 Share on other sites More sharing options...
LLapsus Posted October 14, 2011 Author Share Posted October 14, 2011 Thanks, I will have a look and use it, if necessary. Quote Link to comment https://forums.phpfreaks.com/topic/249139-searching-for-next-event-in-a-list/#findComment-1279441 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.