I have a basic MySQL query:
$getFeed = "SELECT posts.postID, posts.postTitle, .....
FROM posts
LEFT JOIN users ON posts.userID = users.id
LEFT JOIN postScore ON posts.postID = postScore.postID
GROUP BY posts.postID
$feedResult = mysql_query($getFeed) or die;
while($row1 = mysql_fetch_array($feedResult)){
$postOwner = $row1["userID"];
$postID = $row1["postID"];
etc...
}
So now here is where I am stuck. I want to order the feed using PHP by some sort of combination of votes, timestamp, etc. Basically create a very simple score algorithm. I would need to use some of the variables above to to do the math, then display the results in order. How can I do that with PHP ?
Other question, should I do this on the fly with PHP or save the algorithm "score" in the DB then just order by that column?
EDIT: Lets say I store the score the DB, however this "score" would be based off an algorithm that is time sensitive (meaning the score would change as time passes). Would it be appropriate to create a backend script that ran at an interval to update all the scores in the DB?