Cibiņš Posted October 14, 2009 Report Share Posted October 14, 2009 (edited) Tatad man šis skripts atspoguļo postus. Bet kā var izdarīt lai parāda lapā 5 postus? Ja ir teiksim vairāk par 5 postiem tad pēdējie 5 jaunakie posti paliek, savukārt vecākie tā kā pāriet uz arhīviem un apakšā ir poga "Arhīvs" zem 5 jaunākajiem postiem ??? <table border="0" cellpadding="0" cellspacing="0"> <tr> <td><?php if (!isset($_GET['MBID'])) exit; function showpost(&$parent) { extract($parent, EXTR_PREFIX_ALL, "msg"); $msg_DateSubmitted = date("d. F Y", $msg_DateSubmitted); ?> <tr> <td rowspan="2" class="dateActual"><p class="dateActual2"><?php echo "$msg_DateSubmitted" ?></p></td> <td class="actAreas"><?php echo "$msg_Title" ?> <br /></td> <td rowspan="2" class="arrowAreaAd"><img src="../resources/pictures/_pic/arrow.png" alt="arrow" width="15" height="86" /></td> <td rowspan="2" class="pictureAreaActual"><?php echo "$msg_Picture" ?></td> </tr> <tr> <td class="readMore"><a class="actLinks" href="?pg=read&Msg=<? echo "$msg_ID" ?>">› lasīt vairāk</a></td> </tr> <tr> <td colspan="4"><div class="lineDiv"></div></td> </tr> <? $result = mysql_query("SELECT ID, Title, Picture, DateSubmitted FROM pg_home_data WHERE MBID = {$_GET['MBID']} AND Parent = $msg_ID ORDER BY DateSubmitted DESC;"); if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { showpost($row); } } } $result = mysql_query("SELECT ID, Title, Picture, DateSubmitted FROM pg_home_data WHERE MBID = {$_GET['MBID']} AND Parent = 0 ORDER BY DateSubmitted DESC;"); if (!$result) exit; if (!mysql_num_rows($result)) { echo "<p class='dateActual2'>Pagaidām nav ievietotu rakstu!</p>"; } else { while ($row = mysql_fetch_assoc($result)) { showpost($row); } } ?></td> </tr> <tr> <td id="bufferDnAreaControl"> <a class="actLinks" href="#">›› Aktualitāšu arhīvs</a> // Šis paradās ja ir vairak par 5 rakstiem lapā un dodas uz arhīvu kur ir vecāki raksti. </td> </tr> <tr> <td id="bufferDnArea"></td> </tr> </table> Edited October 14, 2009 by MCWeb.lv Quote Link to comment Share on other sites More sharing options...
Turecky Posted October 14, 2009 Report Share Posted October 14, 2009 Pieprasījumam pieliec beigās LIMIT 5, tad atgriezīs tikai 5 ierakstus. Attiecīgi pie arhīva sadaļas vari vai nu rādīt visus, vai arī jaunākos piecus novāk, tas jau kā vēlies. Quote Link to comment 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.