Help with a code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Phuck
Forum Newbie
Posts: 4
Joined: Thu Jul 18, 2013 3:52 pm

Help with a code

Post 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.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Help with a code

Post by AbraCadaver »

Are these PHP files, HTML files, is anything coming from the DB? Or just when you make modifications to the file?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Phuck
Forum Newbie
Posts: 4
Joined: Thu Jul 18, 2013 3:52 pm

Re: Help with a code

Post 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.
Phuck
Forum Newbie
Posts: 4
Joined: Thu Jul 18, 2013 3:52 pm

Re: Help with a code

Post 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.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Help with a code

Post 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";
    }
}
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Phuck
Forum Newbie
Posts: 4
Joined: Thu Jul 18, 2013 3:52 pm

Re: Help with a code

Post 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!
Post Reply