PHP MySQL Display - Php Mysql Create Database - Phptpoint.com

PHP MySQL Select

/ins>

PHP MySQL Display Data

The SELECT statement is used to display data from a table.

To display all data from a table use select(*) statement and to display particular field’s data use select filed1,filed2 at the place of (*).

Syntax

Ex(PHP MySQL Display Data)

The example above stores the data returned by the mysql_query( ) function in the $data variable.

Next, we use the mysql_fetch_array( ) function to return the first row from the recordset as an array.

Each call to mysql_fetch_array( ) returns the next row in the recordset. The while loop loops through all the records in the recordset.

To print the value of each row, we use the PHP $r variable ($r[’emp_id’], $r[‘name’],$r[’email’] and $r[‘mobile’]).

Select values from table using list( ) function

The example above stores the data returned by the mysql_query( ) function in the $data variable.

Next, we use the mysql_fetch_array( ) function to return the first row from the recordset as list($id,$name,$eid,$mob) funtion in variable $id,$name,$eid,$mob. 1st field values stored in $id, 2nd in $name, 3rd in $eid and 4th values in $mob . Now print variables $id, $name, $eid, $mob.

Display the Records inside Table