Mam panel, który wyświetla mi 3 pliki z downloadu z wybranej kategorii.
Kategoria o id=4
include LOCALE.LOCALESET."downloads.php";
$i = 0;
$id_cat = 4;
// Number of news displayed
$items_per_page = 3;
// Filter form, list of existing cats and downloads
if (!isset($_GET['download_id']) || !isnum($_GET['download_id'])) {
$cat_result = dbquery(
"SELECT download_cat_id, download_cat_name, download_cat_description, download_cat_access, download_cat_sorting
FROM ".DB_DOWNLOAD_CATS."
WHERE ".groupaccess('download_cat_access').$filter." AND download_cat_id='$id_cat'
ORDER BY download_cat_name");
if (dbrows($cat_result)) {
while($cat_data = dbarray($cat_result)) {
echo "<div class='firma lista'>";
echo "<h1>FIRMY: ".$cat_data['download_cat_name']."</h1><br />\n";
if (isset($_GET['cat_id']) && isnum($_GET['cat_id']) && $cat_data['download_cat_description'] != "") {
echo "<p>".$cat_data['download_cat_description']."</p>\n";
}
if (checkgroup($cat_data['download_cat_access'])) {
echo "<!--pre_download_cat-->";
$rows = dbcount("(download_id)", DB_DOWNLOADS, "download_cat='".$cat_data['download_cat_id']."'");
if (!isset($_GET['rowstart'.$cat_data['download_cat_id']]) || !isnum($_GET['rowstart'.$cat_data['download_cat_id']]) || $_GET['rowstart'.$cat_data['download_cat_id']] > $rows) { $_GET['rowstart'.$cat_data['download_cat_id']] = 0; }
if ($rows != 0) {
$result = dbquery(
"SELECT td.download_id, td.download_user, td.download_datestamp, td.download_image_thumb, td.download_cat,
td.download_title, td.download_version, td.download_count, td.download_description_short,
tu.user_id, tu.user_name, tu.user_status,
SUM(tr.rating_vote) AS sum_rating,
COUNT(tr.rating_item_id) AS count_votes
FROM ".DB_DOWNLOADS." td
LEFT JOIN ".DB_USERS." tu ON td.download_user=tu.user_id
LEFT JOIN ".DB_RATINGS." tr ON tr.rating_item_id = td.download_id AND tr.rating_type='D'
WHERE download_cat='".$cat_data['download_cat_id']."'
GROUP BY download_id
LIMIT ".$_GET['rowstart'.$cat_data['download_cat_id']].",".$items_per_page);
$numrows = dbrows($result); $i = 1;
while ($data = dbarray($result)) {
if ($data['download_datestamp'] + 604800 > time() + ($settings['timeoffset'] * 3600)) {
$new = " <span class='small'>".$locale['410']."</span>";
} else {
$new = "";
}
if ($data['download_image_thumb']) {
$img_thumb = DOWNLOADS."images/".$data['download_image_thumb'];
} else {
$img_thumb = DOWNLOADS."images/no_image1.jpg";
}
$comments_count = dbcount("(comment_id)", DB_COMMENTS, "comment_type='D' AND comment_item_id='".$data['download_id']."'");
echo "<div class='main-body floatfix news-body' >\n";
//if ($settings['download_screenshot']) {
// echo "<img src='".$img_thumb."' style='float: right; margin:0px 0px 0px 0px' alt='".$data['download_title']."' />\n";
//}
echo "<h2><i class='fa fa-caret-right'></i> <a href='http://www.tomaszowiak.tv/firmy.php?cat_id=".$cat_data['download_cat_id']."&download_id=".$data['download_id']."'>".$data['download_title']."</a></h2>\n";
echo "</div>";
echo "<div class='spacer' ><div class='news_info middle-border floatfix' ><ul>";
echo "<li>tel.: ".($data['download_version'] ? $data['download_version'] : "--")."</li>\n";
if ($data['download_description_short']) {
echo "<li>".nl2br(stripslashes($data['download_description_short']))."</li>";
}
echo "</ul>\n";
echo "</div></div>\n";
}
}
echo "</div>\n";
}
}
} else {
echo "<div style='text-align:center'><br />\n".$locale['430']."<br /><br />\n</div>\n";
}
}
Panel domyślnie wyświetla pliki posortowane według ich ID. Jednak chciałbym aby wyświetlane były 3 ostatnio dodane pliki (czyli żeby sortowało według daty). Co powinienem zmienić?
PW od moderatora:
- Przeniesienie tematu - bogdan 20.05.2014 19:25
|