Hi, This is a reaction to a post(http://www.daniweb.com/forums/thread1720.html) thats a bit old, and I wanted to ask something, but it suggested I'd better start a new post. I'm sorry if theres another post going about this, but I couldnt really find the search function (just joined).
First of all I want to say it's a very nice and clean script but im having some problems getting it to work. I dont get any errors but it just refuses to go to a next record, when I click one of the buttons it just stays on the same page and nothing changes. I'm testing this with a database with 6 records, and it does display the links to go to the next page but it just doesnt work.
Here's the changed part of my code:
$db = mysql_connect($server, $user, $pass)or die(mysql_errno() . ": " . mysql_error() . "<br>");
mysql_select_db($databasename, $db) or die(mysql_errno() . ": " . mysql_error() . "<br>");
$sql = "SELECT * FROM contacts ";
$query = mysql_query($sql,$db);
$total_results = mysql_num_rows($query);
$limit = "1"; //limit of archived results per page.
$total_pages = ceil($total_results / $limit); //total number of pages
if (empty($page)){
$page = "1"; //default page if none is selected
}
$offset = ($page - 1) * $limit; //starting number for displaying results out of DB
$query = "SELECT * FROM contacts LIMIT $offset, $limit ";
$result = mysql_query($query);
//This is the start of the normal results...
while ($row = mysql_fetch_array($result)){
echo "<h1><center>" . $row['Naam'] . "(" . $row['Leeftijd'] . ")</center></h1><br />\n";
}
mysql_close();
I've been trying to fix a previous/next script all day but I keep running into the same problem. Have no idea why it doesnt work, because nobody seems to have the same trouble.
Hoping someone can help,
Thanks in advance