Code:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1" bgcolor="#CCCCCC"></td>
<td height="200" align="center" valign="top"><table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" align="left" class="naslovstranicereg">REZULTATI PRETRAGE NA OSNOVU ZADATIH PARAMETARA</td>
</tr>
<tr>
<td height="1" align="left" class="tackiceh"></td>
</tr>
<tr>
<td height="40" align="left" class="tabtext">U sljedećoj tabeli nalazi se baza podataka ugovornih organa u Bosni i Hercegovini pretražena po zadatim parametrima pretrage i sortirana po abecednom redu. Ukoliko želite da saznate više o pojedinom ugovornom organu kliknite na link "Opširnije" u koloni, "Detaljne info". </td>
</tr>
<tr>
<td height="5"></td>
</tr>
<tr>
<td height="20"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1" height="20"></td>
<td width="50" height="20" align="left" valign="middle" bgcolor="#CCCCCC" class="tabheader">R. br.</td>
<td width="1" height="20" align="left" valign="middle"></td>
<td height="20" align="left" valign="middle" bgcolor="#CCCCCC" class="tabheader">Naziv ugovornog organa</td>
<td width="1" height="20" align="left" valign="middle"></td>
<td width="100" height="20" align="left" valign="middle" bgcolor="#CCCCCC" class="tabheader">Vrsta</td>
<td width="1" height="20" align="left" valign="middle"></td>
<td width="150" height="20" align="left" valign="middle" bgcolor="#CCCCCC" class="tabheader">Nivo kojem pripada</td>
<td width="1" height="20" align="left" valign="middle"></td>
<td width="100" align="left" valign="middle" bgcolor="#CCCCCC" class="tabheader">Detaljne info</td>
<td width="1" align="left" valign="middle"></td>
</tr>
</table></td>
</tr>
<tr>
<td height="20" align="center">
<?php
include('konekcija.php'); // include your code to connect to DB.
$tbl_name="registar"; //your table name
// How many adjacent pages should be shown on each side?
$adjacents = 3;
/*
First get total number of rows in data table.
If you have a WHERE clause in your query, make sure you mirror it here.
*/
$query = "SELECT COUNT(*) as num FROM $tbl_name";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
/* Setup vars for query. */
$targetpage = "index.php?id=01a&jezik=bs"; //your file name (the name of this file)
$limit = 3; //how many items to show per page
$page = $_GET['page'];
if($page)
$start = ($page - 1) * $limit; //first item to display on this page
else
$start = 0; //if no page var is given, set start to 0
/* Setup page vars for display. */
if ($page == 0) $page = 1; //if no page var is given, default to 1.
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
/*
Now we apply our rules and draw the pagination object.
We're actually saving the code to a variable in case we want to draw it more than once.
*/
$pagination = "";
if($lastpage > 1)
{
$pagination .= "<div class=\"pagination\">";
//previous button
if ($page > 1)
$pagination.= "<a href=\"$targetpage&page=$prev\">« nazad</a>";
else
$pagination.= "<span class=\"disabled\">« nazad</span>";
//pages
if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
}
elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some
{
//close to beginning; only hide later pages
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"$targetpage&page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"$targetpage&page=$lastpage\">$lastpage</a>";
}
//in middle; hide some front and some back
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= "<a href=\"$targetpage&page=1\">1</a>";
$pagination.= "<a href=\"$targetpage&page=2\">2</a>";
$pagination.= "...";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"$targetpage&page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"$targetpage&page=$lastpage\">$lastpage</a>";
}
//close to end; only hide early pages
else
{
$pagination.= "<a href=\"$targetpage&page=1\">1</a>";
$pagination.= "<a href=\"$targetpage&page=2\">2</a>";
$pagination.= "...";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
}
}
//next button
if ($page < $counter - 1)
$pagination.= "<a href=\"$targetpage&page=$next\">dalje »</a>";
else
$pagination.= "<span class=\"disabled\">dalje »</span>";
$pagination.= "</div>\n";
}
?>
<?php
// Retrieve data from database
$naziv = $_POST['naziv'];
$vrsta = $_POST['vrsta'];
$nivo = $_POST['nivo'];
$sql=("SELECT id,naziv,vrsta,nivo FROM registar WHERE naziv like '%$naziv%' and vrsta like '%$vrsta%' and nivo like '%$nivo%' order by naziv ASC LIMIT $start, $limit");
$result=mysql_query($sql);
// Define $color=1
$color="1";
echo '<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="tabtext">';
while($rows=mysql_fetch_array($result)){
// If $color==1 table row color = #FFFFFF
if($color==1){
echo "<tr height='20' bgcolor='#FFFFFF'>
<td width='50' align='left' valign='middle'>".$rows['id']."</td>
<td width='' align='left' valign='middle'>".$rows['naziv']."</td>
<td width='100' align='left' valign='middle'>".$rows['vrsta']."</td>
<td width='150' align='left' valign='middle'>".$rows['nivo']."</td>
<td width='100' align='left' valign='middle'><a href=index.php?id=01uo&uo=".$rows['id']."&jezik=bs>Opširnije</a></td>
</tr>";
// Set $color==2, for switching to other color
$color="2";
}
// When $color not equal 1, use this table row color
else {
echo "<tr height='20' bgcolor='#F0F0F0'>
<td width='50' align='left' valign='middle'>".$rows['id']."</td>
<td width='' align='left' valign='middle'>".$rows['naziv']."</td>
<td width='100' align='left' valign='middle'>".$rows['vrsta']."</td>
<td width='150' align='left' valign='middle'>".$rows['nivo']."</td>
<td width='100' align='left' valign='middle'><a href=index.php?id=01uo&uo=".$rows['id']."&jezik=bs>Opširnije</a></td>
</tr>";
// Set $color back to 1
$color="1";
}
}
echo '</table>';
mysql_close();
?>
<?=$pagination?>
</td>
</tr>
<tr>
<td height="20"> </td>
</tr>
</table></td>
<td width="1" bgcolor="#CCCCCC"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1" bgcolor="#CCCCCC"></td>
<td height="200" align="center" valign="top"><table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" align="left" class="naslovstranicereg">REZULTATI PRETRAGE NA OSNOVU ZADATIH PARAMETARA</td>
</tr>
<tr>
<td height="1" align="left" class="tackiceh"></td>
</tr>
<tr>
<td height="40" align="left" class="tabtext">U sljedećoj tabeli nalazi se baza podataka ugovornih organa u Bosni i Hercegovini pretražena po zadatim parametrima pretrage i sortirana po abecednom redu. Ukoliko želite da saznate više o pojedinom ugovornom organu kliknite na link "Opširnije" u koloni, "Detaljne info". </td>
</tr>
<tr>
<td height="5"></td>
</tr>
<tr>
<td height="20"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1" height="20"></td>
<td width="50" height="20" align="left" valign="middle" bgcolor="#CCCCCC" class="tabheader">R. br.</td>
<td width="1" height="20" align="left" valign="middle"></td>
<td height="20" align="left" valign="middle" bgcolor="#CCCCCC" class="tabheader">Naziv ugovornog organa</td>
<td width="1" height="20" align="left" valign="middle"></td>
<td width="100" height="20" align="left" valign="middle" bgcolor="#CCCCCC" class="tabheader">Vrsta</td>
<td width="1" height="20" align="left" valign="middle"></td>
<td width="150" height="20" align="left" valign="middle" bgcolor="#CCCCCC" class="tabheader">Nivo kojem pripada</td>
<td width="1" height="20" align="left" valign="middle"></td>
<td width="100" align="left" valign="middle" bgcolor="#CCCCCC" class="tabheader">Detaljne info</td>
<td width="1" align="left" valign="middle"></td>
</tr>
</table></td>
</tr>
<tr>
<td height="20" align="center">
<?php
include('konekcija.php'); // include your code to connect to DB.
$tbl_name="registar"; //your table name
// How many adjacent pages should be shown on each side?
$adjacents = 3;
/*
First get total number of rows in data table.
If you have a WHERE clause in your query, make sure you mirror it here.
*/
$query = "SELECT COUNT(*) as num FROM $tbl_name";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
/* Setup vars for query. */
$targetpage = "index.php?id=01a&jezik=bs"; //your file name (the name of this file)
$limit = 3; //how many items to show per page
$page = $_GET['page'];
if($page)
$start = ($page - 1) * $limit; //first item to display on this page
else
$start = 0; //if no page var is given, set start to 0
/* Setup page vars for display. */
if ($page == 0) $page = 1; //if no page var is given, default to 1.
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
/*
Now we apply our rules and draw the pagination object.
We're actually saving the code to a variable in case we want to draw it more than once.
*/
$pagination = "";
if($lastpage > 1)
{
$pagination .= "<div class=\"pagination\">";
//previous button
if ($page > 1)
$pagination.= "<a href=\"$targetpage&page=$prev\">« nazad</a>";
else
$pagination.= "<span class=\"disabled\">« nazad</span>";
//pages
if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
}
elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some
{
//close to beginning; only hide later pages
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"$targetpage&page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"$targetpage&page=$lastpage\">$lastpage</a>";
}
//in middle; hide some front and some back
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= "<a href=\"$targetpage&page=1\">1</a>";
$pagination.= "<a href=\"$targetpage&page=2\">2</a>";
$pagination.= "...";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"$targetpage&page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"$targetpage&page=$lastpage\">$lastpage</a>";
}
//close to end; only hide early pages
else
{
$pagination.= "<a href=\"$targetpage&page=1\">1</a>";
$pagination.= "<a href=\"$targetpage&page=2\">2</a>";
$pagination.= "...";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
}
}
//next button
if ($page < $counter - 1)
$pagination.= "<a href=\"$targetpage&page=$next\">dalje »</a>";
else
$pagination.= "<span class=\"disabled\">dalje »</span>";
$pagination.= "</div>\n";
}
?>
<?php
// Retrieve data from database
$naziv = $_POST['naziv'];
$vrsta = $_POST['vrsta'];
$nivo = $_POST['nivo'];
$sql=("SELECT id,naziv,vrsta,nivo FROM registar WHERE naziv like '%$naziv%' and vrsta like '%$vrsta%' and nivo like '%$nivo%' order by naziv ASC LIMIT $start, $limit");
$result=mysql_query($sql);
// Define $color=1
$color="1";
echo '<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="tabtext">';
while($rows=mysql_fetch_array($result)){
// If $color==1 table row color = #FFFFFF
if($color==1){
echo "<tr height='20' bgcolor='#FFFFFF'>
<td width='50' align='left' valign='middle'>".$rows['id']."</td>
<td width='' align='left' valign='middle'>".$rows['naziv']."</td>
<td width='100' align='left' valign='middle'>".$rows['vrsta']."</td>
<td width='150' align='left' valign='middle'>".$rows['nivo']."</td>
<td width='100' align='left' valign='middle'><a href=index.php?id=01uo&uo=".$rows['id']."&jezik=bs>Opširnije</a></td>
</tr>";
// Set $color==2, for switching to other color
$color="2";
}
// When $color not equal 1, use this table row color
else {
echo "<tr height='20' bgcolor='#F0F0F0'>
<td width='50' align='left' valign='middle'>".$rows['id']."</td>
<td width='' align='left' valign='middle'>".$rows['naziv']."</td>
<td width='100' align='left' valign='middle'>".$rows['vrsta']."</td>
<td width='150' align='left' valign='middle'>".$rows['nivo']."</td>
<td width='100' align='left' valign='middle'><a href=index.php?id=01uo&uo=".$rows['id']."&jezik=bs>Opširnije</a></td>
</tr>";
// Set $color back to 1
$color="1";
}
}
echo '</table>';
mysql_close();
?>
<?=$pagination?>
</td>
</tr>
<tr>
<td height="20"> </td>
</tr>
</table></td>
<td width="1" bgcolor="#CCCCCC"></td>
</tr>
</table>
damaki