Ok, so basically I am setting up a little bit of a text database. The data file contains just a list of items, with item ID, expire date, and description on each line. I want to write a script to read each line and display a summary with items not past the expiry date organised under a current heading and items 0-4 months past the expiry date under an old heading, and older items not displayed. each item has the description then a link, the link loads an html file for each item. the html file I will make the ID in the data file, the id probably by default being the line number, not that that's important.
So this is what I'm thinking.
1) define 2 arrays, current and expired
2) define the data file
3) define date into number (eg (DMY) 30102003) then i can use simple math on the date.
4) fscanf the file
fscanf ($handle, "%[^]|%[^]|%[^]\n"))
5) test each item by date, if date after current then put in current array. if 0-4months after put in expired array.
if ($expDate => $currentDate) { //for current array } else if { //for expired array }
(obviously that just being the gist of it 😉 )
6) place item in the array, the item being an array with the ID, exp date, description
7) write current header and items in current array (easy)
8) same for expired array
Then I'm done. It doesnt matter what order I add items with regards to the exp date and no maintanence required, old items will simple be knocked off the list. An exp date will always be defined. I will put handling for incase a category is empty ("no current/expired items avalible")
Please help me fill in the gaps. Also this probally isnt the best way to do it, its just how i'm working towards doing it at the moment. Thanks