+ Reply to Thread
Results 1 to 8 of 8

Thread: PHP paging help

  1. #1
    ChiBuki is offline x10Hosting Member ChiBuki is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    11

    PHP paging help

    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.

  2. #2
    mephis's Avatar
    mephis is offline x10Hosting Member mephis is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    London, UK
    Posts
    39

    Re: PHP paging help

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

  3. #3
    ChiBuki is offline x10Hosting Member ChiBuki is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    11

    Re: PHP paging help

    Yup, tried that and it won't echo.

  4. #4
    AttackBunnyPro is offline x10Hosting Member AttackBunnyPro is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    26

    Re: PHP paging help

    I'm assuming that you did, in fact, connect to the database and took those bits of code out for security reasons?

  5. #5
    ChiBuki is offline x10Hosting Member ChiBuki is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    11

    Re: PHP paging help

    Quote Originally Posted by AttackBunnyPro
    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 Code:
    <?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 by ChiBuki; 11-06-2008 at 09:59 PM. Reason: Text formatting

  6. #6
    natsuki's Avatar
    natsuki is offline x10 Sophmore natsuki is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    112

    Re: PHP paging help

    oops this is what it's echoing
    PHP Code:
    // 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 Code:
    $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

  7. #7
    ChiBuki is offline x10Hosting Member ChiBuki is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    11

    Re: PHP paging help

    Ah so that was it. Thank you so much!!!

  8. #8
    natsuki's Avatar
    natsuki is offline x10 Sophmore natsuki is an unknown quantity at this point
    Join Date
    Sep 2008
    Posts
    112

    Re: PHP paging help

    no prob^^

+ Reply to Thread

Similar Threads

  1. Ever Been Suspended For Using PHP?
    By dragoneye_xp in forum Off Topic
    Replies: 26
    Last Post: 08-16-2009, 07:17 PM
  2. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  3. currently have an application pending php
    By biomasti in forum Free Hosting
    Replies: 1
    Last Post: 09-03-2008, 01:58 PM
  4. php errors galore
    By DMG Online in forum Scripts & 3rd Party Apps
    Replies: 9
    Last Post: 05-17-2008, 06:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers