OK i have a page whara i want to show DB data, now when the DB gets more and more entrys i whish to have a pagination "NEXT 1 2 3 4 5...PREVIUS". So this is what i'v tryed: but tgis is only giving me "NEXT and PREVIUS" links.
Code:
<?php
$databasename='****'; // Name of the database
$tablename='jobadd'; // Name of the table
$mysqladd='****'; // Address to the MySQL Server
$mysqluser='****'; // Your MySQL UserName
$mysqlpass='****'; // Your MySQL Password
if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) {
//we give the value of the starting row to 0 because nothing was found in URL
$startrow = 0;
//otherwise we take the value from the URL
} else {
$startrow = (int)$_GET['startrow'];
}
$query="SELECT * FROM jobadd ORDER BY Timestamp DESC LIMIT $startrow, 10";
echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+10).'">Nästa </a>';
$prev = $startrow - 10;
//only print a "Previous" link if a "Next" was clicked
if ($prev >= 0)
echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.$prev.'">Föregående</a>';
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) :
?>
<div class="blogitem" style="display: block;">
<div class="blogdivider"><img src="./images/devider.gif" width="100%" height="1px" border="0"><br></div>
<font face="Arial" color="#666666" style="font-size:10px"><?php echo mysql_result($result,$i,"ID"); ?> | </font> <font face="Arial" color="#666666" style="font-size:10px">Datum:
<?php echo mysql_result($result,$i,"Time_of_submission"); ?></font>
<br><div class="blogsubject"> <?php echo mysql_result($result,$i,"Vad"); ?> | <?php echo mysql_result($result,$i,"Var"); ?>
| <?php echo mysql_result($result,$i,"Postnr"); ?> | ID Kod: <?php echo mysql_result($result,$i,"Idkod"); ?></a><br></div>
<font face="Arial" color="#282828" style="font-size:13px"><br></font>
<br>
<font face="Arial" color="#FF0000" style="font-size:13px"><b> När skall Uppdraget börja:</b></font>
<br>
<?php echo mysql_result($result,$i,"När"); ?>
<a href="http://jobler.se/svara.php?ID=<?php echo mysql_result($result,$i,"ID"); ?>&Idkod=<?php echo mysql_result($result,$i,"Idkod"); ?>"><img src="images/senaste6_0217.png" id="svarShape3" alt="" title="" style="position:absolute;left:270px;border-width:0;width:280px;height:81px;"></a>
</div>
<br>
<font face="Arial" color="#FF0000" style="font-size:13px"><b> Uppdragets uppskattade pris:</b></font>
<br>
<?php echo mysql_result($result,$i,"Pris"); ?> kr
<br>
<br>
<br>
<br>
<br>
<font face="Arial" color="#FF0000" style="font-size:13px"><b> Beskrivning av uppdrag:</b></font>
<br>
<?php echo mysql_result($result,$i,"Beskrivning"); ?>
<br>
<br>
<br>
<br>
<?php
$i++;
endwhile;
?>
</body>
</html>
Bookmarks