Thanx for pointing that out. After performing the search I found a number of useful scripts. I tried the following, however, I receive the error:
Notice: Undefined index: country in c:\Apache\htdocs\mlresultspagefinal.php on line 13
You have specified an invalid page number
Any Idea why? Many Thanks.
<?
//connect to server and select database
$conn = mysql_connect("localhost", "root", "")
or die(mysql_error());
mysql_select_db("test",$conn) or die(mysql_error());
//choose the amount of stats you want to display in one page
$per_page = 3;
/original code // retrieve data from database
$sql_text = "SELECT FROM jobs";/
$COUNTRY = $_REQUEST['country'];
//create and issue the query
$sql_text = "SELECT
FROM USERDETAILS
WHERE COUNTRY = '$COUNTRY'
ORDER BY GENDER";
if(!isset($GET['page'])){
$page = 1;
}else{
$page = $GET['page'];
}
//set up the variables for the prev and next links
$prev_page = $page - 1;
$next_page = $page + 1;
//get the data from the database
$query = mysql_query($sql_text);
/set up specified page, so we have set $per_page to 3 we need to figure out the starting page based on the amount of data recieved from the database. mysql_num_rows() will get the no. of rows in the result from our mysql_query/
$page_start = ($per_page * $page) - $per_page;
$num_rows = mysql_num_rows($query);
if ($num_rows <= $per_page){
$num_pages = 1;
}elseif (($num_rows % $per_page) == 0) {
$num_pages = ($num_rows / $per_page);
}else{
$num_pages = ($num_rows / $per_page) + 1;
}
$num_pages = (int) $num_pages;
if ($page > $num_pages || $page < 0) {
echo 'You have specified an invalid page number'
;}
$sql_text = $sql_text." LIMIT $page_start, $per_page";
$query = mysql_query($sql_text);
?>
<html>
<head>
<title>All Users</title>
</head>
<body>
<p>There are currently <? echo "$num_rows"; ?> files in this section</p>
<?
// previous link. we need a if statement to determine if prev page is not equal to 0, then echo the url for the link
if ($prev_page != 0){
echo '<a href="MLresultsPageFinal.php?page='.$prev_page.'">prev</a> |';
}
//displays the next link
if ($page != $num_pages) {
echo '|<a href="MLresultsPageFinal.php?page='.$next_page.'">Next</a>';
}
?>
<?php // This calls the data to be displayed.
while ($info = mysql_fetch_assoc($query)) {
echo("<p>\n"
. "<b>job Firstname:</b> " . $info["FIRSTNAME"] . "<br />\n"
. "<b>job Lastname:</b> " . $info["LASTNAME"] . "<br />\n"
. "<b>COUNTRY:</b> " . $info["COUNTRY"] . "<br />\n"
. "<b>contact:</b>\n");
echo("<hr style=\"color:black;width:500px;text-align:left;\">\n\n\n\n");
}
?>
</body>
</html>