Home » , » Tutorial – Development of News System with PHP and MySQL

Tutorial – Development of News System with PHP and MySQL

jaki watson | 22:15 | 0 comments

PHP Mysql Development
In this tutorial, we are going to develop an online news system with PHP and a MySQL background. Talking about an online news system, it is a virtual newspaper that allows reader to select separate title to read. In technical words, we can say that a news system is simple web application, enabling to list news and read more details when you select on particular news title.

There are many leading newspaper migrating online to reach more readers through internet. Somewhere, people can’t find newspaper due to their locations and thus, they prefer reading online only. One of the best advantages of read news online is it allows to choose news of your choice and can enable to browse news achieves irrespective of the publication date. Browsing this tutorial helps to develop simple news site with just few steps.

Step 1: Set up PHP environment

In the first step of the tutorial, you have to make your computer ready for the development of news site. Developers have to know system requirements and how to get it prepared. Below given configurations are to be used in PHP development.
  • OS: Windows 7
Usually, any operating system can work, just you have to know how to use it and install your software.
  • Text Editor: Komodo Edit
There are many text editors you can choose from. Some of them are Netbeans, Eclipse, Intype, Sublime Text, Dreamweaver, Notepad++, etc. Here, I personally prefer Komodo Edit.
  • Local Web Server: WAMP
WAMP abbreviated for Windows Apache Mysql and Php. With this, you can easily install three various servers that used for developing system functions. Apache is a server that processes all web requests while Mysql is a database for inserting and retrieving data.

PHP, here, is a server that interprets function of PHP programming language. Developer can’t able to use PHP program without this PHP server. Apache Server shows all PHP code in the plain text. Lastly, Windows, an operating system is used to create news system.

If you are using Linux operating system then you have to opt for MAMP for Mac OS, LAMP for Linux systems, XAMPP for all systems, EasyPHP for windows, etc.

Step 2: System definition

In project section, we need an online news system that has news titles. When a reader clicks on the title, he/she will reach to next page for reading in details. It is advisable to make the titles accessible that already at the home page.
We will require two web pages, i.e. index.php and display.php.

Remember, if you are not using the .php extensions, you won't be able to add PHP code inside.

Now, you were thinking why choosing index.php file. Let me tell you, it is considered as the entrance of the website and it loads first whenever anyone visits a web site. Thus, index becomes the home page of the website.
Moving towards the next step, you have to create the layout by using HTML.

Step 3: Creating the System Layout Using HTML

With the help of the HTML code, we have created a new file and named it as index.php then copy and paste the below code:



Step 4: Create the database using MySql

Now, we require database, where one can store their whole news. It’s time to open PhpMyAdmin, a database management system and create the latest database and name it as the News.
Run the below given SQL queries after the database is developed.
You can create SQL request to create table news:


Step 5: Make the Whole System Work Using PHP
Now, we have seen our database ready. In next step, we have to place together the whole engine and make it work properly. Being the best programming language, PHP helps to create a dynamic website with an ease.
Now, we have to change some points in your HTML code in index.php as given below:

Add this code on top of the index page:











Replace this segment...


...with this code.









Now, you have to make a new page (file) with a name read-news.php and add this code. In this file, you haven’t added HTML code, just adding PHP will worthy.

PHP code in read-news.php




Explanation Regarding Coding

Here, we have created the connection to the database before any transaction from line 2 to 7. With Line 9, you can check whether news title is clicked and the unique ID defined in the database, which is transmitted to the read-news.php. Otherwise, the script will jump from line 10 to line 17 and can run only in Line 19, which is an error message.

The unique ID is fetched by Line 10 in to a variable "$news_id" and ensures the ID is an integer(a number). A request to our database is only ran by Line 11 and Line 12 fetches the feed-back(news content) of the request into variable "$news_content".

Now, you have to display content with title in one HTML heading tag followed by the date. The full content of the news is displayed by the Line 16 and last one, line 17 that shows the author name in the HTML heading tag.

Step 6: Possible improvements

Apart from above mentioned things, you can simply add many things to make it Pro such as: Organize your news in categories, add a good CSS, a back office, more managers, images related to your news and so on.

With these steps, we can create new pages for managing news system. If you are looking for news site for your business then adopt PHP Professional Developer for hire service from Perception System. For more information about Custom PHP Web Development service, click here.
Share this article :

0 comments:

Post a Comment

 
Design by: