Obecnie na swojej strone mam mini forum. I chciałbym zrobić aby tematy na tym forum wyświetlany były w kolejności weług dat pisanych postów. Czyli po prostu aby temat do którego ostatnio był napisany post wyświetlał mi się na górze listy.
Obecnie moje forum polega w podobny sposób jak newsy.
Tabela comments:
CREATE TABLE `comments` (
`comment_id` int(11) NOT NULL AUTO_INCREMENT,
`art_id` int(11) NOT NULL DEFAULT '0',
`type_id` varchar(32) NOT NULL DEFAULT '',
`user_id` varchar(32) DEFAULT NULL,
`COMMENT` text,
`time` varchar(32) NOT NULL DEFAULT '',
`date` varchar(32) NOT NULL DEFAULT '',
PRIMARY KEY (`comment_id`)
) TYPE=MyISAM AUTO_INCREMENT=145 ;
Tabela z tematami:
CREATE TABLE `czacik_tematy` (
`temat_id` int(11) NOT NULL AUTO_INCREMENT,
`tytul` varchar(255) NOT NULL DEFAULT '',
`tresc` text NOT NULL,
`data` varchar(16) NOT NULL DEFAULT '',
`godzina` varchar(16) NOT NULL DEFAULT '',
`autor` varchar(16) NOT NULL DEFAULT '',
PRIMARY KEY (`temat_id`)
) TYPE=MyISAM AUTO_INCREMENT=14 ;
Część kodu odpowiedzialna za wyświetlanie listy tematów:
<?
$porcja=10;
$wiersz=0+$dawka;
$sql = \"select * from czacik_tematy ORDER BY temat_id DESC limit $wiersz, $porcja\";
$sql1 = \"select * from czacik_tematy ORDER BY temat_id\";
$bg = ( $i_cos % 2 ) ? '#2E2E2E' : '#222222';
$id = $rowee[\"temat_id\"];
$sql3 = \"select * from comments where art_id = '$id' and type_id = 5\";
print(\"<tr bgcolor=\"$bg\"><td style=\"padding-left:15px\"> <a href=\"czacik.php?temat=\".$rowee[\"temat_id\"].\"\">\".$rowee[\"tytul\"].\"</a></td><td>\".$rowee[\"autor\"].\"</td><td>\".$rowee[\"data\"].\"</td><td>$cnt</td></tr> \"); $i_cos++;
}
?>
<tr><td colspan=\"4\" align=\"center\">
<?
$r=$wiersz-$porcja;
$f=$wiersz+$porcja;
if($r >= 0){
echo \"( <a href=czacik.php?main&dawka=$r>Poprzednia strona</a> ) \"; }
if($f < $vol){
echo \"( <a href=czacik.php?main&dawka=$f>Nastepna strona</a> )\"; }
?>
Będe wdzięczny za pomoc (IMG:
http://forum.php.pl/style_emoticons/default/smile.gif)