Sort Comment From Bottom To Top [Like Facebook Comments]

Fait

Seasoned Veteran
Joined
Oct 15, 2010
Messages
4,407
Reaction score
561
FP$
2,054
First I apologize for the long code I can't be bothered at this point to mess with the code it's already frustrating me enough (i am human do get angry..)

Anyway,
What I am trying to do is display the latest comments in the database I have tried DESC this displays comments from top to below which is alright but not what I need I also tried ASC and that's not displaying the most recent comments as I have a LIMIT.

I need it to work exactly how the facebook comment system works if that makes more sense but nothing is working :/

(Yes i know its loong but you will earn great reputation if you can help)

Here's the code

$select_comments2 = $db->query("
SELECT * FROM " . TABLE_PREFIX . "groups_comments WHERE post_id='$escape_post_id_row' AND post_id='$_GET[pid]' ORDER BY comment_id DESC LIMIT 10");
 
Please for the love of god stop using mysql_* functions and don't use SELECT *

I've been reading through all your support threads and you seem to be using mysql_* functions. They are depreciated, and I know you're new to PHP but you shouldn't be using them for new projects.



Use PDO or MySQLi.

Something simple in PDO:
Code:
<?
 $stmt = $db->prepare("SELECT name, id, email, mood FROM profile WHERE id=:id AND name=:name ");
 $stmt->bindValue(':id', $id, PDO::PARAM_STR);
 $stmt->bindValue(':name, $name, PDO::PARAM_STR);
 $stmt->execute();
?>

But like the other user said, why are you doing two select where causes on the same column?
 

Attachments

  • depre.webp
    depre.webp
    18 KB · Views: 86
I'm making a group feature like Facebook and I'm not new to php but this pdo stuff is new to me.

I tried still doesn't work DESC sorts it from top to bottom.

I don't think it's the mysql_ function it's the mybb $db->query so I need to program it exactly how they do there queries.


can't use PDO i'm coding for Mybb
Call to undefined method DB_MySQLi:😛repare() and Mybb already use MYSQLi.<br /><br />-- July 20th, 2014, 4:29 pm --<br /><br />It's JQuery i'm new to and to be honest I hate using JQuery sometimes lol, Rather stick to pure PHP with some JQuery.
 
Back
Top Bottom