Alright, another post. This one seems to be the most complex thing I have ever tried. So, I am making a site where a user can post jokes and vote on them. They can only vote up, so a digg like system. I want the users to be able to sort the list of jokes by vote within the last 24 hours. In other words, jokes posted within the last 24 hours , whichever has the most will be on top.
As of now, I am fetching jokes via a mysql query and a while array. It can sort jokes by category (by retrieving URL variable catid) right now, an I need it to also sort by Daily Top, and Weekly top. There can be potentially 2 variables in the url (like index.php?catid=3&sort=daily), so I need too know how I would sort the data. Would I sort the array or the query. I wanted to do it by query, but I don't know how to specify a time range in the query.
I have ideas on how I would implement it, just got to find out how to code it. I have been researching for about an hour and still am. The links below are what I have gathered through my research. I don't know if they are any help, but it's worth a shot.
Jump to Post
I'd use query rather than sort via array.
You could have a table like:
joke_id | today | previous
You could run a cronjob at midnight to transfer add today to previous and setting today to 0.
THis just looks at last 24 hours and …
Jump to Post
I'm no expert so all I can do is offer my opinion...
When working with php and mysql, I always try to fetch the optimal results first in mysql and if I can't do it with mysql then I'll format with PHP. IF you have a date/time field in …
All 9 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.