Datum-Sortierung Kommentare

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

Post Reply
Lazy
Posts: 19
Joined: Wed Jul 30, 2003 12:31 pm
Contact:

Datum-Sortierung Kommentare

Post by Lazy »

hi :)

also ich würd gerne die neusten Kommentare auf der startseite anzeigen lassen, was auch hervorragend klappt *g* aber der sortiert mir`s nicht nach den letzten/neusten 5 kommentaren irgendwie und ich blicks ned, wieso ned *g*

das is die funktion, die ich benutz:

Code: Select all

	function generateKom() {
	global $db, $sqltblpre;
	$result = $db->query("SELECT DISTINCT ".$sqltblpre."faqcomments.id, ".$sqltblpre."faqcomments.user, ".$sqltblpre."faqcomments.email, ".$sqltblpre."faqcomments.comment, ".$sqltblpre."faqcomments.datum, ".$sqltblpre."faqdata.thema, ".$sqltblpre."faqdata.id FROM ".$sqltblpre."faqcomments, ".$sqltblpre."faqdata WHERE ".$sqltblpre."faqcomments.id = ".$sqltblpre."faqdata.id ORDER BY ".$sqltblpre."faqcomments.datum DESC LIMIT 0,5");
	if ($num = $db->num_rows($result) > 0) {
		$output = "";
		while ($row = $db->fetch_object($result)) {
			$output .= "\t\t<tr>\n";
			$output .= "\t\t\t<td valign=\"top\" class=\"fivenewest\"><a href=\"".$row->email."\">".stripslashes(makeShorterText($row->thema, 4))."</a></td>\n";
			$output .= "\t\t\t<td valign=\"top\" class=\"fivenewest\"><a href=\"mailto:".$row->email."\">".$row->user."</a></td>\n";
			$output .= "\t\t\t<td valign=\"top\" class=\"fivenewest\" nowrap>".stripslashes(makeShorterText($row->comment, 9))."</td>\n";
			$output .= "\t\t</tr>\n";
			}
		}
	else {
		$output = "<tr class=\"fivenewest\"><td>Keine Kommentare</td></tr>";
		}
	return $output;
	}
hoffe, einer siehts, wieso nicht die neusten 5 kommentare angezeigt werden *g* ach ja, das der artikel/thema link noch ned stimmt weiß ich *g*
Thorsten
Posts: 15724
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

probiers mal mit dem Query:

Code: Select all

SELECT  DISTINCT faqcomments.id, faqcomments.user, faqcomments.email, faqcomments.comment, faqcomments.datum, faqdata.thema, faqdata.id
FROM faqcomments, faqdata
WHERE faqcomments.id = faqdata.id
ORDER  BY faqcomments.id_comment ASC 
LIMIT 0 , 5
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Lazy
Posts: 19
Joined: Wed Jul 30, 2003 12:31 pm
Contact:

Post by Lazy »

klappt! :) super, danke Thorsten ! :)
Post Reply