PHP paging help

ChiBuki

New Member
Messages
11
Reaction score
0
Points
0
Hello,

Currently I have a table with over 50 entries and I'm trying to apply "Next" and "Previous" links for it using this tutorial: http://www.php-mysql-tutorial.com/php-mysql-paging.php

So far the Next and Previous links are working but I can't figure out how to echo from my database. It's either working links but the rows are not echoing, or the rows appear but the links aren't working.

This is the page live.
This is the page in html with PHP: I uploaded it as text file

It's supposed to look like this but there's a problem with my old script. It works fine in other browsers, but not for people with Windows XP and Firefox 3. The "Older »" link does not go all the way to entry #1 for unknown reason. Which is why I gave up on my script and used the tutorial above.

I don't need anything fancy; just a simple and effective Next and Previous links for my table. If you could help me to reach a solution I'd really appreciate it.

Thanks in advance.
 

mephis

New Member
Messages
39
Reaction score
0
Points
0
Where you have:
PHP:
while(list($row) = mysql_fetch_assoc($result))

I don't think you need to call list()... try:
PHP:
while($row = mysql_fetch_assoc($result))
 

AttackBunnyPro

New Member
Messages
26
Reaction score
0
Points
0
I'm assuming that you did, in fact, connect to the database and took those bits of code out for security reasons?
 

ChiBuki

New Member
Messages
11
Reaction score
0
Points
0
AttackBunnyPro said:
I'm assuming that you did, in fact, connect to the database and took those bits of code out for security reasons?
I always use include('connect.php'); (separated in another file) to connect, so it'd be easier to change if I'm using other databases.

This is the file and that should be all the codes necessary~

PHP:
<?php
//Set Up database Info
$db_host = 'localhost';
$db_database = 'mydatabase';
$db_username = 'myusername';
$db_password = 'mypassword';

// Make connection
$connection = mysql_connect($db_host,$db_username,$db_password);
if(!$connection)
{
die("Could not connect to the database:<br />". mysql_error());
}

// Select database
$db_select = mysql_select_db($db_database);
?>
 
Last edited:

natsuki

New Member
Messages
112
Reaction score
0
Points
0
oops this is what it's echoing
PHP:
// how many rows we have in database
$query   = "SELECT COUNT(ID) AS Number FROM TsundereOrNot";
$result  = mysql_query($query) or die('Error, query failed');
$row     = mysql_fetch_assoc($result);
$numrows = $row['Number'];
instead of what you intended to
PHP:
$query  = "SELECT ID, Shoujo, Rank, Average, TotalVotes, FivePoints, FourPoints, ThreePoints, TwoPoints, OnePoints, DateUpdated FROM TsundereOrNot ORDER BY ID DESC LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die('Error, query failed');
change the ordering of the queries or requery the SELECT of the actual table after the count
 
Top