Pagination In Flatfile

Discussion in 'PHP' started by koolasia, Dec 26, 2006.

Thread Status:
Not open for further replies.
  1. #1
    is pagination in flat file possible

    like depenind on the number of files in a folder or something like dat
     
    koolasia, Dec 26, 2006 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Yes... Post your code.
     
    nico_swd, Dec 26, 2006 IP
  3. koolasia

    koolasia Banned

    Messages:
    1,413
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i want the code for when there are 172 files in a folder

    i want 50 files to be displayed per page how can i do that
     
    koolasia, Dec 26, 2006 IP
  4. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #4
    Barti1987, Dec 26, 2006 IP
  5. koolasia

    koolasia Banned

    Messages:
    1,413
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    0
    #5
    koolasia, Dec 26, 2006 IP
  6. pixel_perfect

    pixel_perfect Banned

    Messages:
    238
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    do like this mak sort files and do simple pagination, rest is same just exclude the mysql part.
     
    pixel_perfect, Dec 27, 2006 IP
  7. drewbe121212

    drewbe121212 Well-Known Member

    Messages:
    733
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    125
    #7
    If the flat file's records are seperated on a per line basis

    open the file
    explode the data by "\r" (carriage return)
    Count the newly created array from the explode

    You now have how many records are in your file. Pagination is childs play once you know that.
     
    drewbe121212, Dec 27, 2006 IP
  8. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #8
    I believe that the \r is only added on Windows machines. I think it's safer to use this method to get the number of records.

    
    
    $records = sizeof(file('your-file.txt'));
    
    PHP:
     
    nico_swd, Dec 28, 2006 IP
  9. koolasia

    koolasia Banned

    Messages:
    1,413
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Wat if its not in a text file but there are many files in a folder in same format
     
    koolasia, Dec 28, 2006 IP
  10. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #10
    The extension doesn't matter as long as each record is in a new line. As for the folder question, what do you want to do? Count all files in a folder?

    
    
    $files = sizeof(glob('/path/to/files/*.txt'));
    
    
    PHP:
    You can play with glob(). What format do your files have?
     
    nico_swd, Dec 28, 2006 IP
  11. koolasia

    koolasia Banned

    Messages:
    1,413
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    0
    #11
    i want them the count and do pagination for them like

    if 100 files are there

    i want 15 to appear per page

    and then pages like 1 2 3 4 5 6 etc etc appear
     
    koolasia, Dec 28, 2006 IP
Thread Status:
Not open for further replies.