Mam pewien kłopot z posortowaniem. Otóż mam tabele forum_topic i forum_post i chce posortowac wszystkie tematy malejąco po ostatnim dodanym poscie w danym temacie.
Fragment kodu:
<?php
elseif(@$_GET['id_forum_watek'] && @$_GET['id_forum_dzial'])
{
naglowekforum("Zobacz forum numer ".@$_GET['id_forum_dzial']."");
echo "<a href='index.php?id_forum_dzial=".@$_GET['id_forum_dzial']."&id_forum_watek=".@$_GET['id_forum_watek']."&czynnosc=utworz_topic'>Utwórz nowy temat</a>\n"; echo "<table align='center' width='90%' border='1' style='border-collapse: collapse'><tr bgcolor='#CCCFF'>"; echo "<th colspan='2'>Ważne tematy</th><th width='50'>Posty</th><th width='100'>Autor</th><th width='150'>Ostatni post</th>\n"; echo "<table align='center' width='90%' border='1' style='border-collapse: collapse'><tr bgcolor='#CCCFF'>"; echo "<th colspan='2'>Tematy</th><th width='50'>Posty</th><th width='100'>Autor</th><th width='150'>Ostatni post</th>\n";
$query4 = "SELECT * FROM forum_topic WHERE id_forum_dzial = '".@$_GET['id_forum_dzial']."' AND id_forum_watek='".@$_GET['id_forum_watek']."'";
$result4 = mysqli_query
($mysql, $query4) or
die('zapytanie: '.$query4.'---blad:'.mysqli_error
($mysql));
while ($row4 = mysqli_fetch_assoc($result4))
{
echo "<tr><td>=></td><td width='60%'><a href='index.php?id_forum_dzial=".@$_GET['id_forum_dzial']."&id_forum_watek=".@$_GET['id_forum_watek']."&id_forum_topic=".$row4['id_forum_topic']."'>".$row4['tytul']."</a><br />".$row4['podtytul']."</td><td>";
$query8 = "SELECT * FROM forum_post WHERE id_forum_topic = '".$row4['id_forum_topic']."'";
$result8 = mysqli_query
($mysql, $query8) or
die('zapytanie: '.$query8.'---blad:'.mysqli_error
($mysql)); $liczba_postow = mysqli_num_rows($result8);
echo "".$liczba_postow."</td><td>";
$query5 = "SELECT nick FROM forum_uzytkownicy WHERE id_forum_user = '".$row4['id_forum_user']."'";
$result5 = mysqli_query
($mysql, $query5) or
die('zapytanie: '.$query5.'---blad:'.mysqli_error
($mysql)); while ($row5 = mysqli_fetch_assoc($result5))
{
echo "".$row5['nick']."</td><td>"; }
$query6 = "SELECT data_powstania, id_forum_user FROM forum_post WHERE id_forum_topic =
'".$row4['id_forum_topic']."' ORDER BY data_powstania DESC LIMIT 0,1";
$result6 = mysqli_query
($mysql, $query6) or
die('zapytanie: '.$query6.'---blad:'.mysqli_error
($mysql)); while ($row6 = mysqli_fetch_assoc($result6))
{
echo "".$row6['data_powstania']."<br />"; $query7 = "SELECT nick FROM forum_uzytkownicy WHERE id_forum_user = '".$row6['id_forum_user']."'";
$result7 = mysqli_query
($mysql, $query7) or
die('zapytanie: '.$query7.'---blad:'.mysqli_error
($mysql)); while ($row7 = mysqli_fetch_assoc($result7))
{
echo "".$row7['nick']."</td>"; }
}
}
}
?>