This example illustrates how to display result on the browser and how to use the result in the php application.
To understand how to display the result returned
from the sql query execution, we have created sql_result.php page. First,
connection from database is created using mysql_connect("hostName",
"userName", "Password"), database is selected by
mysql_select_db("databaseName", connectionObject). Now, query "
SELECT * FROM users"
is executed using mysql_query() method to select the data from the table
"users" in the database. The result is stored in the "
result" variable in php. The iteration can be performed using while
statement as given below:
echo $row['username'] . " " . $row['email'];
Source Code of sql_result.php
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial