Hi,
I got a problem with pagination. I got a script but the problem is that I use the connection to database with "mysqli" NOT "mysql". Im newbe with mysqli and I dont know how can I change the pagination script to work.
<?php
$dbConnect= mysqli_connect('localhost', 'user', 'password') or die('Cant connect');
mysqli_select_db($dbConnect, 'database') or die('Cant connect to database');
mysqli_set_charset($dbConnect, "utf8");
?>
And this is a script for pagination
<?php
$limit = 4;
$sql = "select count(c_vesti_id) from c_vesti";
$c = array_shift(mysql_fetch_row(mysql_query($sql)));
$maxpage = ceil($c / $limit);
$page = isset($_GET['page']) ? abs((int)$_GET['page']) : 1;
if ($page <= 0)
{
$page = 1;
}
else if ($page >= $maxpage)
{
$page = $maxpage;
}
$offset = ($page-1) * $limit;
$query = mysql_query("select * from c_vesti limit $offset, $limit ");
while ($row = mysql_fetch_assoc($query))
{
print $row['c_vesti_naslov']."<br />";
}
//
$linklimit = 4;
$linklimit2 = $linklimit / 2;
$linkoffset = ($page > $linklimit2) ? $page - $linklimit / 2 : 0;
$linkend = $linkoffset+$linklimit;
if ($maxpage - $linklimit2 < $page)
{
$linkoffset = $maxpage - $linklimit;
if ($linkoffset < 0)
{
$linkoffset = 0;
}
$linkend = $maxpage;
}
if ($page > 1)
{
print "<a href='?page=".($page-1)."'>Back</a> ";
}
for ($i=1+$linkoffset; $i <= $linkend and $i <= $maxpage; $i++)
{
$style = ($i == $page) ? "color: black;" : "color: blue;";
print "<a href='?page=$i' style='$style'>[$i]</a> ";
}
if ($page < $maxpage)
{
print "<a href='?page=".($page+1)."'>Forward</a>";
}
?>
Thanks in advanced for help
T