Dysan Posted May 23, 2008 Share Posted May 23, 2008 Hi, How do I store a list of Firstnames & Surnames inside a .txt file, then using PHP, limit the amount of data displayed per page to only 6 records. Depending on the number of records stored in the .txt file, a NEXT and PREVIOUS link is enabled/disabled. Extremely Appreciated! Link to comment https://forums.phpfreaks.com/topic/106971-split-file-data/ Share on other sites More sharing options...
947740 Posted May 23, 2008 Share Posted May 23, 2008 May I recommend a database? Link to comment https://forums.phpfreaks.com/topic/106971-split-file-data/#findComment-548307 Share on other sites More sharing options...
Barand Posted May 23, 2008 Share Posted May 23, 2008 I'd read them into an array using file() then use array_slice() to the get the six I want to display depending on page number. You'll need extra code, but this is main bit <?php $names = file('mynames.txt'); // read text into an array $total_pages = ceil(count($names)/6); $offset = ($page-1)*6; // get offset from page number $page_names = array_slice($names, $offset, 6); // get array of the 6 names on this page ?> Link to comment https://forums.phpfreaks.com/topic/106971-split-file-data/#findComment-548312 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.