SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member jihadun_nafs's Avatar
    Join Date
    Jul 2006
    Location
    jakarta, IndonesiA
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PREV 1 2 3 NEXT.. problem

    hi all...my id is jihadun_nafs(it is mean strunggle from himself)

    i have a code to make "PREV 1 2 3 NEXT" , the problem is if i click the "1 2 3" the data is still same. any one can help me ?

    it is the code

    PHP Code:
    <html><head><title>Explore Provisioning limited</title></head><body>
    <?
    @$urut=1;
    @
    $startdate=$_POST['startdate'];
    @
    $enddate=$_POST['enddate'];

    $db=mysql_connect("DbaseSNOC.indosat.com""root","") or die('Koneksi gagal dibangun:' .mysql_error());
    mysql_select_db("wo",$db)or die('Database yang dimaksudkan tidak ada :' .mysql_error());

    //$offset=$newoffset;
    $limit=20// rows to return
    $numresults=mysql_query("select * from Prov where (status !='Done') order by tgl_wo");
    $numrows=mysql_num_rows($numresults);

    // next determine if offset has been passed to script, if not use 0
    if (empty($offset)) {
        
    $offset=1;
    }

    // get results
    $result=mysql_query("select * ".
        
    "from Prov where (status !='Done')".
        
    "order by tgl_wo limit $offset,$limit");

    echo
    "<table border=1 bordercolor=Azure>";
    echo
    "<tr><td Colspan=17 align=center>WO Received between ";echo $startdate;echo" and "; echo $enddate;
    echo
    "</td></tr>";
    echo 
    "<tr> <th>No</th> <th>WO Date</th> <th>WO</th> <th>Segment</th> <th>Customer</th> <th>E1</th><th>DS3</th><th>STM1</th> <th>Rfs date</th> <th>Scope</th> <th>PJ</th> <th>XConn</th> <th>Status</th> <th>Edit</th> <th>Pending</th><th>Lead</th><th>File</th><th>   Remark   </th>
    <th></th></tr>"
    ;


    // now you can display the results returned
    while ($data=mysql_fetch_array($result)) {
        
    // include code to display results as you see fit

    // next we need to do the links to other results

    if ($offset==1) { // bypass PREV link if offset is 0
        
    $prevoffset=$offset-20;
        print 
    "<a href=\"ExploreProvlimit.php?offset=$prevoffset\">PREV</a> &nbsp; \n";
    }

    // calculate number of pages needing links
    $pages=intval($numrows/$limit);

    // $pages now contains int of pages needed unless there is a remainder from division
    if ($numrows%$limit) {
        
    // has remainder so add one page
        
    $pages++;
    }

    for (
    $i=1;$i<=$pages;$i++) { // loop thru
        
    $newoffset=$limit*($i-1);
        print 
    "<a href=\"ExploreProvlimit.php?offset=$newoffset\">$i</a> &nbsp; \n";
    }

    // check to see if last page
    if (!(($offset/$limit)==$pages) && $pages!=1) {
        
    // not last page so give NEXT link
        
    $newoffset=$offset+$limit;
        print 
    "<a href=\"ExploreProvlimit.php?offset=$newoffset\">NEXT</a><p>\n";
    }


    ?>
    </body>
    </html>
    Last edited by sweatje; Jul 10, 2006 at 19:49. Reason: add php code tags
    Best Regard's


    jihadun_nafs

  2. #2
    SitePoint Enthusiast ada80ro's Avatar
    Join Date
    Apr 2005
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, I haven't looked very carefully at your code but I think you should read this tutorial:
    http://www.phpfreaks.com/tutorials/73/1.php

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not sure if this will totally solve your problem, but the first thing i saw is $_POST should be $_GET

  4. #4
    Evil Genius MilchstrabeStern's Avatar
    Join Date
    Nov 2003
    Location
    Arizona
    Posts
    1,131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I glanced over your code, and it looks OK, with the suggestions listed above. The onle thing I would suggest is modifying your query statements. They might work fine, but, it's a good idea to keep your queries readable. In otherwords:

    select * from table where id ='id'
    should be:
    SELECT * FROM table WHERE id='id'
    Is it so hard to shift?
    ]


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
  •