Forum Moderators: coopster

Message Too Old, No Replies

How Can I Sort Lists and Expire Listings?

         

Tehuti

4:47 pm on Aug 23, 2008 (gmt 0)

10+ Year Member Top Contributors Of The Month



Just as an example, imagine that on my web site I have a list of times during which a movie will be shown at different cinemas. For example:

12:00 Odeon
13:00 UCI
14:00 Cineworld
15:00 Odeon
16:00 UCI

Questions:

1) How can I get each listing to delete itself once it has expired?

2) How can I make it so that the list can be sorted into New, Expiring and Most Popular (most clicked)?

3) How can I get some of the listings to also show on other pages? For example, all of the Odeon listings to show on my Odeon page?

I realise that my questions are very broad. However, I don't expect anyone to do this for me. Please just give me a basic outline, so that I can learn and do it all myself.

surrealillusions

5:20 pm on Aug 23, 2008 (gmt 0)

10+ Year Member



Best way is via a mysql database. I presume your running apache/linux server?

If the time of the movie is in the past, dont show it.

If the time of the movie is within the next, say, 6 hours, then it can go into an 'expiring' part of the site.

For example

expiring movies -
echo all those movies that times are within the next 6 hours of the server time

You can track each click through another script that auto-increments a table in the database each time its clicked. You can then list the database by ascending or descending by that table.

There are probably numerous ways to do this but that hopefully gives you a basic outline to work off

:)

henry0

9:41 pm on Aug 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Tehuti, welcome to WebmasterWorld!
1) You need to be more precise in the delete meaning
Do you mean delete as "delete (no undo)" or delete meaning not "published"?

Anyway we are speaking MySQL database here.
If only published is considered, that’s the easier case: add a column published size 1, default=n.
Create a little script that will update (at your will) the published col to ‘y’
To un-publish edit again and set it to ‘n’
The web page will query the database where publish=’y’

Next deleting “for good”
Read about crontab and cron job, if you need a little tutorial about setting it up:
I have that somewhere here, let me know and I’ll find its WebmasterWorld link.

2) You need to look for time and date in the PHP manual
I would add a column timestamp that will be activated as soon as a new row is added
The rest is reading about timestamp and how comparing “now” with the timestamp
For example if you need to delete something a week old you will create a cron job script that will delete rows WHERE timestamp+1week

3) to show anywhere else your content from a database only requires to duplicate the original script (showing the initial content) and modifying it with your requirement parameters (called a sub-query) for example … where listing =’$odeon’ AND published =’y’ etc..

I never remember where it is but if a Mod in good mood :) read this he will provide you with that link about the basic of grabbing data from a MySQL DB

Good luck, keep us posted.

coopster

12:19 pm on Aug 25, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I never remember where it is but if a Mod in good mood :) read this he will provide you with that link about the basic of grabbing data from a MySQL DB

Always in a good mood, henry0 :)
I think the link that you are referring to is the one in the PHP Forum Library [webmasterworld.com] that gets pointed to quite often: Basics of extracting data from MySQL using PHP [webmasterworld.com]

henry0

12:33 pm on Aug 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I know! :) and this time I bookmarked it! thanks.

Tehuti

2:27 am on Aug 26, 2008 (gmt 0)

10+ Year Member Top Contributors Of The Month



surrealillusions, thanks for the help! You sound like you know your stuff. Unfortunately, I am very new to PHP, having just started learning it a few days ago! It will therefore take a while for me to understand exactly what you said.

Wow! Henry0, you, too, sound like you know your stuff. However, as with surrealillusions' response, I didn't understand a word of what you said!

One thing you both mentioned is that MySQL databases will be needed. I'll start learning that stuff right now and get back to you.

Coopster, thanks for the resource!