Hi thanks for the replies,
here is my code which i currently have limited to 25 results per page.
<?PHP
//connect to database
$conn = mysql_connect($host, $username, $password) or die(mysql_error());
mysql_select_db($database,$conn) or die(mysql_error());
$limit = 25;
$query_count = "SELECT * letting_agents" or die (mysql_error());
$result_count = mysql_query($query_count);
$totalrows= mysql_num_rows($result_count);
// Check if $page variable is empty
if(empty($page)) {
$page=1;
}
$limitvalue = $page * $limit - ($limit);
$query = "SELECT * FROM letting_agents order by company ASC LIMIT $limitvalue, $limit";
$result = mysql_query($query) or die (mysql_error());
if(mysql_num_rows($result) == 0)
{
echo "Nothing to Display!";
}
$bgcolor = "#E0E0E0";
?>
<table>
<?php
while($row = mysql_fetch_array($result))
{
if($bgcolor == "#E0E0E0")
{
$bgcolor = "#FFFFFF";
}
else
{
$bgcolor = "#E0E0E0";
}
?>
<tr bgcolor = "<?php echo $bgcolor; ?>">
<td><?php echo $row ['company']; ?></td>
<td><?php echo $row ['email']; ?></td>
<? } ?>
</table>
<?php
// Next and Previous Links
if($page != 0){
$pageprev = $page-1;
echo("<a href=\"".$_SERVER['PHP_SELF']."?page=$pageprev\">PREV</a> ");
}
else
{
echo("PREV".$limit." ");
}
$numofpages = $totalrows / $limit;
for($i = 1; $i <= $numofpages; $i++){
if($i == $page){
echo($i." ");
}
else
{
echo("<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ");
}
}
if(($totalrows % $limit) >1){
if($i == $page){
echo($i." ");
}
else
{
echo("<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ");
}
}
if(($totalrows - ($limit * $page)) < 1){
$pagenext = $page+1;
echo("<a href=\"".$_SERVER['PHP_SELF']."?page=$pagenext\">NEXT ".$limit."</a>");
}
else
{
echo("NEXT".$limit);
}
// mysql_free_result($result);
?>
I want to select from <<Prev A BC... NEXT>> I had the code one but cannot find how to produce the alphabet to then use to link <a href=\"".$_SERVER['PHP_SELF']."?page=$pagenext\">%A</a>"); or something similar ?
I am also getting a warning re mysql_num_rows any ideas.