WItam, mam problem z wyświtlaniem wyników z bazy MySQL.
Chodzi o to ze na 1 stronie wyswietla sie 10 wyników, na 2 jest 20 a na ktorejs tam jest nawet 30, i niektore sie powtarzaja.
Niżej zamieszczam kod, moze ktos mi powie co w nim jest nie tak?

<?php
if(isset($_GET['typ'])) { $typ = '`typ` = ' . (int) $_GET['typ'];
}else{
$typ = "((`typ` >= 1 and `typ` <= 4) or (typ = '15') or (typ = '16') or (typ = '17'))";
}
//$typ = (isset($_GET['typ']) ? '`typ` = ' . (int) $_GET['typ'] : '((`typ` >= 1 and `typ` <= 4) or (typ = '15'))');
$cat = (isset($_GET['cat']) ?
' and `category` = ' . (int
) $_GET['cat'] : ''); $order = '';
if ($_GET['top'] == 1)
{
$order = ' order by `ocena` desc';
}
elseif ($_GET['last'] == 1)
{
$order = ' order by `added` desc';
}
$res = mysql_query('select * from `stuff` where ' . $typ . $cat); // ilosć trafień
$res = mysql_query('select * from `stuff` where ' . $typ . $cat . $order . ' order by added desc limit ' . ((int
) $_GET['currentpage'] * 1) . ', ' . ((int
) $_GET['currentpage'] * 10
+ 10
)); if ($hits == 0)
{
echo '<center>Ta kategoria jest pusta.</center>'; }
else
{
{
if($row['added']>0)
$date = sprintf('<img src="ikonki/dodano.jpg">Dodano: %s godzina %s<br />', date('Y.m.d', $row['added']), date('H:i:s', $row['added'])); else
$date = (string) '';
$comments_count = (int) 0;
$query = sprintf("SELECT COUNT(*) AS CommentsCount FROM komentarze WHERE stuff='%d'", $row['id']); if($comments) {
$comments_count = $record['CommentsCount'];
}
if($row['miniaturka']!='') {
$image = sprintf('<img src="%s" alt="%s" class="icon"align="right"width="160px"height="120px"border="2" />', $row['miniaturka'], $row['title']); } else {
$image = '';
}
if(isset($categories[$row['category']])) $cat = sprintf("%s: ", $categories[$row['category']]); else
$cat = (string) '';
printf('<table width="420" bgcolor="#F3F3F3" style="margin-bottom:12px;font-family:verdana;font-size:12px;"><tr><td style="text-align:left; clear:both; padding:0 4px;">%s <b>%s</b><a href="index.php?page=display&id=%d" class="stufflink"style="font-weight:bold;">%s</a><br />%s<img src="ikonki/wykres.jpg">Ocena: %d<br /><img src="ikonki/wykres.gif">Wyswietlen: %d<br /><img src="ikonki/trabka.gif">Komentarzy: %d<br /><img src="ikonki/info.gif">Zasugerował: %s</td></tr></table>', $image,
$cat, $row['id'], $row['tytul'],
$date,
$row['ocena'], $row['counter'],
$comments_count, $row['login']);
}
}
/********* NUMEROWANIE *********/
if ($hits !== 0)
{
$temp = min((int
) $_GET['currentpage'] + 50
, ceil((float
) $hits / 9
.0
)); for ($i = max((int
) $_GET['currentpage'] - 50
, 0
); $i < $temp; $i++) {
print("<a href="index
.php?page
=list1
¤tpage
=" . $i . "&cat
=" . $_GET['cat'] . "">" . ($i+1) . "</a> ");
}
}
/*******************************/
?>
Ten post edytował cholew 31.01.2007, 16:41:03