kennywhite Posted October 7, 2011 Share Posted October 7, 2011 I want to make the news feed on my website easier to maintain. I just created a form that I will use to add the information. The form saves the files that it creates as "entry-date-time.txt" and places it in a folder for the year and a sub folder for the month. Such as "2011\09". I have displayed data from a single flat file before, but I am unsure how to go about displaying the data from multiple files. Can anyone show me an example? I want to be able to paginate the data, displaying a number of updates per page from newest to oldest. I don't have MySQL access on the server or I'd just use that, instead. Quote Link to comment https://forums.phpfreaks.com/topic/248652-displaying-information-from-flat-file-db/ Share on other sites More sharing options...
requinix Posted October 7, 2011 Share Posted October 7, 2011 Use glob to get an array of files and paginate that. To read multiple files all you do is use a loop over the many files and output each one like you normally would. Give it a shot and post code if you have problems. Quote Link to comment https://forums.phpfreaks.com/topic/248652-displaying-information-from-flat-file-db/#findComment-1277093 Share on other sites More sharing options...
Psycho Posted October 7, 2011 Share Posted October 7, 2011 Just be aware that to do the pagination requires that you read ALL the data from all the files on every page load - that would be the only way to properly paginate. You *could* implement some "workarounds" to alleviate that based on your specific needs. For example, if you will be updating the news feeds on manual basis, you could could create a script that would read all the data and programmatically create the "pages" as individual files. Then there would be no performance issues when the users are accessing the pages. It's really going to be determined on how much data you need to work with and the various functions you want to support. Quote Link to comment https://forums.phpfreaks.com/topic/248652-displaying-information-from-flat-file-db/#findComment-1277106 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.