SitePoint Sponsor

User Tag List

Page 3 of 3 FirstFirst 123
Results 51 to 54 of 54
  1. #51
    SitePoint Member
    Join Date
    Jan 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice script. How do I display a list of clickable urls per page without a database?

    The included example displaying names works fine. However, if I could figure out how to display only urls and have them appear in a 350 pixel wide table, the script would be perfect.

    ex.

    clickablelink1.php
    clickablelink2.php
    clickablelink3.php
    clickablelink4.php
    ...etc.

    Using...

    <?php
    require_once "Paginated.php";
    require_once "DoubleBarLayout.php";
    ?>
    <html>
    <head>
    <title>Pagination</title>

    <!-- Just a little style formatting. Has no bearing on example -->
    <style type="text/css">
    body {
    font-family: Verdana;
    font-size: 13px;
    }

    a {
    text-decoration: none;
    }

    a:hover {
    text-decoration: underline;
    }
    </style>
    <!-- End style formatting -->
    </head>

    <body>

    <?php
    //create an array of names in alphabetic order. A database call could have retrieved these items
    $names = array("Andrew", "Bernard", "Castello", "Dennis", "Ernie", "Frank", "Greg", "Henry", "Isac", "Jax", "Kester", "Leonard", "Matthew", "Nigel", "Oscar");

    $page = $_GET['page'];

    //constructor takes three parameters
    //1. array to be paged
    //2. number of results per page (optional parameter. Default is 10)
    //3. the current page (optional parameter. Default is 1)
    $pagedResults = new Paginated($names, 10, $page);

    echo "<ul>";

    while($row = $pagedResults->fetchPagedRow()) { //when $row is false loop terminates
    echo "<li>{$row}</li>";
    }

    echo "</ul>";

    //important to set the strategy to be used before a call to fetchPagedNavigation
    $pagedResults->setLayout(new DoubleBarLayout());
    echo $pagedResults->fetchPagedNavigation();
    ?>
    </body>
    </html>

  2. #52
    SitePoint Member
    Join Date
    Jan 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want to paginate a list of article titles and output results as list of clickable URLS (20 per page).

  3. #53
    SitePoint Member
    Join Date
    May 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, nice article! But i dont understand how i can get data from a mysql database insted of an array. Can somebody show my how i will make the query and where to use mysql_fetch_assoc or mysql_fetch_array? And how do i loop the fetch to get all the rows in there?

  4. #54
    #titanic {float:none} silver trophy
    molona's Avatar
    Join Date
    Feb 2005
    Location
    from Madrid to Heaven
    Posts
    8,025
    Mentioned
    211 Post(s)
    Tagged
    1 Thread(s)
    Look at this thread. This may help. It may be a bit complex since it uses queries but also classes.

    http://www.sitepoint.com/forums/show...ght=Pagination

    For something far more simple, this could help

    http://www.php-mysql-tutorial.com/wi...using-php.aspx


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •