해외축구중계스포츠중계축구중계EPL중계스포츠무료중계실시간스포츠
{"id":259,"date":"2017-04-29T08:04:36","date_gmt":"2017-04-29T08:04:36","guid":{"rendered":"https:\/\/www.wdb24.com\/?p=259"},"modified":"2018-04-22T20:44:39","modified_gmt":"2018-04-22T20:44:39","slug":"how-to-fetch-data-mysql-using-php","status":"publish","type":"post","link":"https:\/\/www.wdb24.com\/how-to-fetch-data-mysql-using-php\/","title":{"rendered":"How to fetch data from Mysql using PHP"},"content":{"rendered":"

In this tutorial I am going to show you how to fetch data from mysql using php. Let\u2019s take an example of my last post that was insert data in mysql using php form<\/a>. In that post I have created a form with 2 fields and save both of fields in a mysql table with datetime. In this post we are going to fetch data from posts table. <\/p>\n

Step 1: Create database connection: <\/h3>\n

We have already created database as demo in my previous post so no need to create new database. Only mysql database connection is required. <\/p>\n

\r\n\r\n<\/pre>\n

Step 2: Write and run mysql fetch query<\/h3>\n

$sql<\/code> variable is a sql statement. $result <\/code> is calling mysqli_query()<\/code> function which takes 2 parameter, 1 is a database connection and 2 is a sql statement. <\/p>\n

\r\n\r\n<\/pre>\n

Step 3: Fetch Single row <\/h3>\n

mysqli_fetch_row()<\/code> function is used to fetch row against sql statement.<\/p>\n

\r\n\t$singleRow = mysqli_fetch_row($result);\r\n\tprint_r($singleRow);\r\n<\/pre>\n

If you want fetch all records against $sql<\/code> query then you need to apply while loop.<\/p>\n

\n<\/ins>
\n