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
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: January 20, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles