SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can I add news to website and dynamically update headlines pages without MySQL?

    Hi guys,

    I update a number of website for athletes with news articles...

    I'm doing it manually at the moment so I have to update:

    1. news.php (with date and article title which links to the article)
    2. News Article (with title, date and article text)
    3. includes/latestNews.php (an include latest 3-4 article dates and headline which links to the article - displays on every page via include)

    The News Article is a plain and simple PHP file which is stored in a folder 'assets/news/' and the file is named according to date i.e. a news article today would be 130420 (as in 2013 year, 04 month, 20 day) so they sit in chronological order in the 'news' folder. There is a template page file called viewArticle.php which drags in the appropriate news article by link i.e. viewArticle.php?id=130420

    At the moment, I have to update news.php, latestNews.php and the individual article individually and manually.

    What I would like to do is...

    ...create, edit and add the News Article file (130420) to the 'news' foler as I am currently doing. But, with PHP, set news.php and latestNews.php to read the files in the 'assets/news/' folder to display the latest 4 article dates and linked headlines (for latestNews.php) and display all the dates and linked headlines (for news.php).

    I don't know anything about databases and can't get my head around them so I would rather do it with PHP code. Is this possible?

    Thank you very much and I hope to hear from you.

    SM

  2. #2
    SitePoint Evangelist captainccs's Avatar
    Join Date
    Mar 2004
    Location
    Caracas, Venezuela
    Posts
    516
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by flashead View Post
    What I would like to do is...

    ...create, edit and add the News Article file (130420) to the 'news' foler as I am currently doing. But, with PHP, set news.php and latestNews.php to read the files in the 'assets/news/' folder to display the latest 4 article dates and linked headlines (for latestNews.php) and display all the dates and linked headlines (for news.php).

    I don't know anything about databases and can't get my head around them so I would rather do it with PHP code. Is this possible?
    Yes!
    PHP Code:
    scandir() 
    will read the directory for you.

    http://www.php.net/manual/en/function.scandir.php
    Denny Schlesinger
    web services


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •