SunQuest
 
       Database Articles
  Home arrow Database Articles arrow PHP/MySQL News with Comments
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Forums Sitemap 
Dedicated Servers  
Download TestComplete 
IBM® developerWorks
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE ARTICLES

PHP/MySQL News with Comments
By: Matt Wade
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 8
    2002-09-03

    Table of Contents:
  • PHP/MySQL News with Comments
  • The Tables
  • Displaying the news
  • Displaying the comments
  • Displaying one item with comments
  • Adding comments
  • Summing it up and final script

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    PHP/MySQL News with Comments


    (Page 1 of 7 )

    In this tutorial, you will learn the concepts behind building a news system with PHP and MySQL.

    Some time ago, I wrote two tutorials about creating a news system. Both of those tutorials dealt with using flat files as the method of storage. Today, we will investigate the use of a database backend, specifically MySQL.

    Before we get started, I want to talk a little about my idea of tutorials. When I write a tutorial, it is not my goal to produce a complete working piece of code. Sure, a lot of times there will be a final product that you could use, but why would you want to when you can write your own code? The tutorials I write I meant to introduce concepts and new ideas to you. Maybe show you some aspect of PHP that you didn’t know about.

    So, all I ask is that you don’t skip to the last page of this tutorial and snap the code and expect it to solve all your problems. Read through the tutorial and incorporate the ideas given here with your own and you will have a much better final product.

    Concepts

    Let’s talk a minute about the concepts behind making a news system with PHP and MySQL. First off, the primary goal is to display news. So, the code should, before it does anything else, display news. On the backend, we will have a table to store all this news. We should probably store the news itself, a title for the news, and a date the news was published. Along with that, we will also have a unique id for each piece of news.

    The next thing we want this system to do is allow users to comment on the news we post. We will store these comments in a table separate from the news. The reason for this is that you can have multiple comments per every news item. In database relationships, this is called a “one to many relationship”. In the comments table, we will want to store the comment itself, the name of the user, and the news id that it is associated with. We will also store a unique id for each comment.

    The whole key to adding comments to a news system is to store the news id along with every comment. Without storing the news id, you would have no way to relate the comment back to the proper news item.

    More Database Articles Articles
    More By Matt Wade


       · dfsf
       · Thanks for a great tutorial.
       · hiI've search the web for ages to find a newssystem that does excatly what this...
       · I seem to be getting the problem where it's not showing the news table at all and...
       · sounds like it doesn't interact with your "news"-database as it...
       · file loaded: http://luna-illusions.co.uk/weetom/newsscript.phpThere's no design...
       · Hi.I just love this Tutorial and it works perfectly except for 1 thing. When you...
       · Warning: mysql_connect() [function.mysql-connect]: Access denied for user...
       · I've discovered a problem with this tutorial. The Comment can only be 500 Characters...
       · Tutorial is nice, but previous one was better, this one is just final script cut...
       · Hello Mr/Mrs Tutorial Creator (xD)I'm new toP and MySQL and I suck basically...
     

    DATABASE ARTICLES ARTICLES

    - More on Query Optimization for Oracle Databa...
    - Query Optimization in Oracle
    - Clusters and Other Data Structures for Oracle
    - Using Indexes with an Oracle Database
    - The Basics of Data Structures in Oracle
    - Oracle Data Structures
    - Best Practices for PL/SQL Variables
    - What`s Code Without Variables?
    - Clauses, Sorting, and SQL Queries
    - The From Clause and SQL Queries
    - Query Primer
    - Full Text Searches and Strings
    - Searching with Strings
    - Pattern Matching with Strings
    - Working with Cases of Strings






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway