Range values to be calculated in PHP Loop

This question was asked by a Abdullah on stackoverflow.  So i thought of giving him a better solution.


As you can see from the above image. For a range of number, each number must be added and divided by the length to get the average and then check if the average is greater than or equal to 7.5, he need to set the is heavy value to yes if not No.

Here is the solution i gave him.

Results looks like this.

Hope this will be helpfull. Tnx.  🙂

PDO database insert script – PHP

PDO_MySQL, is the MySQL for PDO. PDO has been introduced in PHP, and the project aims to make a common API for all the databases access, so in theory you should be able to migrate between RDMS without changing any code (if you don’t use specific RDBM function in your queries), also object-oriented.

The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. Each database driver that implements the PDO interface can expose database-specific features as regular extension functions. Note that you cannot perform any database functions using the PDO extension by itself; you must use a database-specific PDO driver to access a database server.


Here is the sample PDO script to insert data in to the database. This script will take the input from post method and insert that in to the database. Using this script to insert values in to the database is very simple. Just download the below code and modify the fields as per your requirements. Also make sure to add your database credentials as well.

Here is the database table


Good Luck!