Jump to content
xisto Community
Sign in to follow this  
jailbox

Pagination

Recommended Posts

Can anyone help me with pagination of a txt file which looks something like this:some message <br/>some message <br/>some message <br/>some message <br/>some message <br/>some message <br/>some message <br/>The <br/> tag is the end of the message. Anyone?

Share this post


Link to post
Share on other sites

Even in regular HTML, <br/> is also correct. Many HTML tags that don't have a closing tag (like <img>) can also be used that way. Anyway, back on topic:I'm sorry, but I have no idea how I could help you...sorry!

Share this post


Link to post
Share on other sites

I suppose you want to provide pagination using PHP. I created a guestbook with pagination for one of my pages. Basically i have all my entries in a MySQL database and using php code i achieve pagination. Maybe if you do not want to use a database, you can modify the algorithmus a little bit to work with text files.
Here is my code:

[/br]<?php[br]    $sql_db     = "Db_Name";[/br]    $sql_user   = "Db_User";[br]    $sql_pass   = "Db_Passwd";[/br]    $sql_table  = "Db_Table";[br]    [/br]    if(isset($pos)==0)[br]        $pos=0; // start position for the page indexer[/br]    $count=3; // number of displayed items per page[br]    [/br]    mysql_connect("localhost", $sql_user, $sql_pass);[br]    mysql_select_db($sql_db);[/br]    $result = mysql_query("select MAX(id) from ".$sql_table.";");[br]    $data = mysql_fetch_assoc($result);[/br]    $size = $data['MAX(id)'];[br]    $result = mysql_query("SELECT * FROM ".$sql_table." where id>".$pos.";");[/br]    if($result)[br]    {[/br]        $i=0;[br]        while(($data = mysql_fetch_assoc($result)) && ($i < $count))[/br]        {[br]            // Here you should add text[/br]            $i++;[br]        }[/br]    }[br]    mysql_close();[/br]    print "<div>Pages:";[br]    for($j=0; $j<$size; $j++)[/br]        if(!($j % $count))[br]            print "<a href=\"book.php?pos=".$j."\">".(($j/$count)+1)."</a>\n";[/br]    print "Total number of entries: ".$size."\n";[br]    if ($pos > 0)[/br]        print "<a href=\"book.php?pos=".($pos-$count)."\">Back</a>\n";[br]    if($size > $pos+$count)[/br]        print "<a href=\"book.php?pos=".($pos+$count)."\">Next</a>\n";[br]?>[/br]


Let me know if i can help you in oder way.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.