Page 1 of 1

Help with a code

Posted: Fri Jul 19, 2013 12:44 pm
by Phuck
Hi people I am new to PHP and still learning and basically am looking to make a script that I just can't seem to get right.. I am practicing and trying different things and I have successfully made a simple news script and an admin section to add/edit/delete so Im not doing to bad, anyway back on track.. Basically when I update pages I want them to automatically go onto the side navigation of my home page with the date and say what page has been updated,e.g:

If I updated the main page and news page I want this to show on my side nav bar:

July 19, 2013
- Main Page Updated.
- Staff Updated.

Then underneath it show the latest updates before the current date like:

July 19, 2013
- Main Page Updated.
- Staff Updated.

July 18, 2013
- News Headlines Updated.

July 17, 2013
- Main Page Updated.

and so on... I did have a friend that had this script and send me it years back but after a while I didn't have use for it and lost it because it's been so long.. Any help would be greatly appriciated.. Thanks people.

Re: Help with a code

Posted: Fri Jul 19, 2013 1:36 pm
by AbraCadaver
Are these PHP files, HTML files, is anything coming from the DB? Or just when you make modifications to the file?

Re: Help with a code

Posted: Fri Jul 19, 2013 2:30 pm
by Phuck
PHP files and nothing from the DB.. just when I go into my FTP server and edit a page or even from forms on my admin section I want it to show the update on my index page.. I remember back when a friend had it I had to CHMOD one of the files to 777 and their was a plain txt file I had to list the pages and what I wanted to appear, e.g:

index.php > Main Page Updated.
news.php > News Updated.

Plus I had to include that file along with some other coding at the top of every file I wanted to show that has been updated.

Thats about all I can remember, the one I was trying I got frustrated with and scraped it but thats why im posting here to basically see if somebody knows how to do this script.

Re: Help with a code

Posted: Fri Jul 19, 2013 2:33 pm
by Phuck
PS. To do it, I am not pushed if I have to take a different approach from how he did or use a DB, I just basically wanted to see if anybody knows how to do this.. Thanks.

Re: Help with a code

Posted: Fri Jul 19, 2013 2:54 pm
by AbraCadaver
I was bored. It will of course need some adjustment. Just save it in a file like menu.php and include that where you want it.

Code: Select all

$pages = array(
    'Main Page' => 'index.php',
    'Staff' => 'staff.php',
    'News Headlines' => 'news.php',
);
$list = array();

foreach($pages as $page => $file) {
    $date = filemtime($file);    
    if(!isset($list[$date])) { $list[$date] = array(); }
    array_push($list[$date], $page);
}
krsort($list);

foreach($list as $date => $pages) {
    echo date('F j, Y', $date) . "<br />\n";
    foreach($pages as $page) {
        echo "- $page Updated<br />\n";
    }
}

Re: Help with a code

Posted: Fri Jul 19, 2013 2:57 pm
by Phuck
Sweet, thanks a lot man... I'l work off it..I think the one I was doing I was just making too complicated.. Anyway thanks again!