Results 1 to 6 of 6

 

Thread: PHP Pagination

  1. #1
    MorleyM
    Guest



    Looking for a bit of help with this, right im using PHP to pull results out of a CSV data feed mostly for price ranges eg, under £10 and the php script that I wrote pulls all the results that show price of less than 10.

    But this tends to bring back a lot of results so im wanting to display say, 10 per page and then have 'next page' links at the bottom of the page. Been searching google, but can only find help and tutorials on doing this with a my sql database, anyone any ideas how to do it from csv?

  2. #2
    scifind
    Guest

    I assume you are using a for loop.
    Difine $counter=0
    Run the loop once with

    $counter = $counter+1;

    Use counter to give total number of records that match the filter.

    use a while loop to recall all results

    use a IF statment to limit the results to 10 per page

    IF(($whileCount>=$record1)&&($whileCount<=$record1 +10)){
    Print(Your print statment);
    }

    I hope that this helps (it should work will need a bit of tinkering though)


  3. #3
    MorleyM
    Guest

    cheers, will give it a tinker and see if I can make anything of it

  4. #4
    MorleyM
    Guest

    *wakes up* no no no ive got that bit!

    I need a bit to put it all on different pages, at the moment ive got:

    // Opens CSV File
    $row = 1;
    $handle = fopen ($csvfile,"r");
    while ($data = fgetcsv ($handle, 1000, ",")) {
    $num = count ($data);
    $row++;

    // Checks price less than 10
    if ($data[4] <= 10) {

    print "tables with loads of stuff in";

    // Close file
    }
    fclose ($handle);

    What i need is some way of counting how many data[4]'s are returned under 10, and then splitting them up. But as I tought myself php, I missed this bit and well... am stuck
    exit; }

  5. #5
    scifind
    Guest


    Ok I THINK this might work, will probably need intergration.


    (you may want to run your S cript once first without the print to count number of rows, divide by 10 to give total number of pages (round up) and print series of links to page.php?pageNo=1 ..etc)

    I hope this helps, if it works I will let you buy me a beer.

    s=c=r=i=p=t

    $row = 1;

    $handle = fopen ($csvfile,"r");
    while ($data = fgetcsv ($handle, 1000, ",")) {



    // Checks price less than 10

    if ($data[4] <= 10) {
    $row++;
    if(($row>=($pageNo*10-9))&&($row>=($pageNo*10))){
    print "tables with loads of stuff in";
    }
    // Close file
    }
    fclose ($handle);

    e=n=d=s=c=r=i=p=t

  6. #6
    MorleyM
    Guest

    After a tweak or two, it works! And the beers as good as yours, cheers. <img src=http://www.gamers-forums.com/smilies/contrib/ruinkai/biggthumpup.gif ALT=":thumb">



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Use vb.net or php to build product feed site?
    By accelerator in forum Programming
    Replies: 2
    Last Post: 18-01-05, 02:32 PM
  2. Anyone anygood with xml, php, mysql and Affiliate Window
    By AnnonnyMouse in forum Affiliate Marketing Lounge
    Replies: 1
    Last Post: 23-09-04, 11:00 AM
  3. Php & Sql
    By Wunderlust1 in forum Programming
    Replies: 8
    Last Post: 20-08-04, 10:22 AM
  4. PHP - No input file specified. - Problem
    By Barry in forum Programming
    Replies: 1
    Last Post: 02-08-04, 10:57 AM
  5. PHP or Browser Timeout?
    By Barry in forum Programming
    Replies: 6
    Last Post: 28-04-04, 01:04 PM

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
  •  
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2