Nasao skriptu na netu za paginaciju ali nece da radi... U tabeli "oglas" imam unete 13 kolone koje treba da se izcitaju... Ne vidim u cemu je problem, kada pokrenem skriptu na prvoj strani mi prikaze sve 13 kolone iz tabele, takodje i na stranici 2 potpuno isto...
<?php
include('db.php');
?>
<link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
<table class="topsite" cellpadding="0" cellspacing="0">
<tr>
<th class="ranking_th">Ranking</th>
<th class="site_th">Site</th>
<th class="votes_th">Votes</th>
</tr>
<?php
//We get the number of websites
$req1 = mysql_fetch_array(mysql_query('SELECT count(`oglas_id`) AS nb FROM `oglas`'));
$nb_site_page = 10;
//We get the current page
if(isset($_GET['page']))
{
$page = intval($_GET['page']);
}
else
{
$page = 1;
}
//We calculate the number of pages and we display pages links
$nbpages = ceil($req1['nb']/$nb_site_page);
if($page<1 or $page>$nbpages)
{
$page = 1;
}
$pages_site = 'Pages: ';
if($page>1)
{
$pages_site .= '<a href="?page='.($page-1).'">Previous</a> ';
}
for($i=1;$i<=$nbpages;$i++)
{
if($i==$page)
{
$pages_site .= '<strong>'.$i.'</strong> ';
}
else
{
$pages_site .= '<a href="?page='.$i.'">'.$i.'</a> ';
}
}
if($page<$nbpages)
{
$pages_site .= '<a href="?page='.($page+1).'">Next</a>';
}
?>
<tr>
<td colspan="3" class="pages"><?php echo $pages_site; ?></td>
</tr>
<?php
//We calculate the first and last message position to display
$first_message = ($page-1)*$nb_site_page;
$last_message = $first_message +$nb_site_page;
$i = $first_message ;
//On affiche les sites
$req2 = mysql_query("SELECT * FROM `oglas`");
while($dnn2 = mysql_fetch_array($req2))
{
$i++;
?>
<tr>
<td class="ranking"><?php echo $i; ?>
</td>
<td class="site"><?php echo $dnn2['oglas_naslov']; ?></a><br />
<?php echo $dnn2['oglas_telefon']; ?><br />
<?php echo $dnn2['oglas_datum']; ?></td>
<td class="votes"><?php echo $dnn2['oglas_id']; ?></td>
</tr>
<?php
}
//We display pages site (again)
?>
<tr>
<td colspan="3" class="pages"><?php echo $pages_site; ?></td>
</tr>
</table>
|