SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    One record by id over several pages

    Please help me with paging by id over several pages.

    This is the listing script for every thread from posts table, this is fine, but what i need is described in the second script that follows this....
    PHP Code:
    echo "<wml>
    <card id=\"card1\" title=\"romania\">
    <do type=\"prev\" label=\"Back\"><prev/></do>
      <p mode=\"wrap\">"
    ;
    include 
    'library/config.php';
    include 
    'library/opendb.php';
    $rowsPerPage 10;
    $pageNum 1;
    if(isset(
    $_GET['page']))
    {
        
    $pageNum $_GET['page'];
    }
    $offset = ($pageNum 1) * $rowsPerPage;
    $query  "SELECT id, user, subject FROM posts ORDER BY id DESC ";           
    $pagingQuery "LIMIT $offset$rowsPerPage";
    $result mysql_query($query $pagingQuery) or die('Error, query failed');
    while(list(
    $id,$user,$subject) = mysql_fetch_array($result))
    {    
    echo 
    "<a href=\"read.php?sid=$sid&amp;id=$id\">$user$subject</a><br/>";
    }
    $result  mysql_query($query) or die('Error, query failed');
    $numrows mysql_num_rows($result);
    $maxPage ceil($numrows/$rowsPerPage);
    if (
    $pageNum 1)
    {
        
    $page $pageNum 1;
    }
    else
    {
        
    $prev  "&gt;&gt;";       // we're on page one, don't enable 'previous' link
        
    echo $prev;
        
    $first "&gt;"// nor 'first page' link
            
    echo $first;
    }
    if (
    $pageNum $maxPage)
    {
        
    $page $pageNum 1;

            echo 
    "<a href=\"romania.php?sid=$sid&amp;page=$page\">Next</a>";

        echo 
    $pageNum ."of" .$maxPage;

        echo 
    "<a href=\"romania.php?sid=$sid&amp;page=$maxPage\">Last Page</a>";

        echo 
    "<a href=\"romania.php?sid=$sid&amp;page=1\">First Page</a>";

    }
    else
    {
        
    $next "&lt;";      // we're on the last page, don't enable 'next' lin
        
    echo $next;
        
    $last "&lt;&lt;"// nor 'last page' link
        
    echo $last;
        echo 
    $pageNum ."of" .$maxPage;
    }

    include 
    'library/closedb.php';
    echo 
    "<br/>
    <a href=\"post.php?sid=
    $sid\">+ post</a><br/>
    <a href=\"/wml/main.php?sid=
    $sid\">+ main</a>
    </p>
    </card>
    </wml>"

    here it is
    PHP Code:
    echo "<wml>";
    $id $_GET['id'];
    include 
    'library/config.php';
    include 
    'library/opendb.php';
    $query  "SELECT * FROM posts WHERE id='$id' ";           
    $result mysql_query($query) or die('Error, query failed');
    while(list(
    $id$user$date$subject$message) = mysql_fetch_array($result))
    {

    echo 
    "<card id=\"card1\" title=\"$subject\">
    <do type=\"prev\" label=\"Back\"><prev/></do>
      <p mode=\"wrap\">"
    ;
        echo
    "subject: $subject<br/>$date<br/>from: $user<br/>------<br/>$message<br/>------";
    }

    include 
    'library/closedb.php';
    echo 
    "<br/>
    <a href="
    /wml/main.php?sid=$sid">+ main menu</a>
    </p>
    </card>
    </wml>"

    how can i make multiple pages for a single record to display per page only 160 characters, as this is for a mobile forum.

    Thank you!
    Last edited by Ernie1; Oct 1, 2005 at 23:14.

  2. #2
    SitePoint Evangelist Scheisskopf's Avatar
    Join Date
    Nov 2004
    Location
    Southampton, UK
    Posts
    537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well firstly (not answering your question), put php inside tags to make it looks nicer. Secondly, stop using echo and use something like ?><?. Mainly because looing at your code gave me a headache.


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
  •