How to fetch data from database in PHP, How to show data in HTML table using PHP.
#FetchDataFromDatabase, #ShowDataInTableInPHP, #HowToDoThis
For further discussion join us on Facebook:---
/ 1184520091737540
Fetch data from database:
PHP mysql_query() function is used to execute select query. Since PHP 5.5, mysql_query() function is deprecated. Now it is recommended to use one of the 2 alternatives.
mysqli_query()
There are two other MySQLi functions used in select query.
mysqli_num_rows(mysqli_result $result): returns number of rows.
mysqli_fetch_assoc(mysqli_result $result): returns row as an associative array. Each key of the array represents the column name of the table. It return NULL if there are no more rows.
NOTE − Always remember to put curly brackets when you want to insert an array value directly into a string.
In above example the constant MYSQL_ASSOC is used as the second argument to mysql_fetch_array(), so that it returns the row as an associative array. With an associative array you can access the field by using their name instead of using the index.
PHP provides another function called mysql_fetch_assoc() which also returns the row as an associative array.