dachshund Posted March 18, 2016 Share Posted March 18, 2016 Hi, I have a query which selects posts that are trending (ie. have had more than 600 views after 2 hours of being live), but now I want to be able to add a little label to the trending posts that says "trending" if the ID is included in this query. Hopefully that makes sense. This is the query I have: $sql = "SELECT *, views / HOUR(TIMEDIFF(NOW(), date)) as avg FROM content WHERE date BETWEEN CURDATE() - INTERVAL 30 DAY AND NOW() - INTERVAL 2 HOUR AND views > 600 AND live = '0' ORDER BY avg DESC LIMIT 8"; Quote Link to comment https://forums.phpfreaks.com/topic/301036-if-id-is-found-in-query/ Share on other sites More sharing options...
QuickOldCar Posted March 18, 2016 Share Posted March 18, 2016 Not enough of your code to tell exact. You do that within your loop. while($row=...................){ if($row('id') == $post_id){ echo "trending"; //$trending = true; } } Quote Link to comment https://forums.phpfreaks.com/topic/301036-if-id-is-found-in-query/#findComment-1532173 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.