Saturday, July 12, 2014

How to pull data from MySql Database

This brief tutorial will explain how to pull data from a MySql Database. This is useful in the event you have had visitors complete data from a feedback form or imported information through another method.

The first step is connecting.

mysql_connect("localhost","username","password");
mysql_select_db("databasename");

Then, build your query.

$query = "select * from tablename";

$results = mysql_query($query);

while($row=mysql_fetch_array($results)) {

$field1 = $row["name"];

echo $field1 . "<br/>";

}

I hope this tutorial was useful. Please check out my new car app for iPhone if you get a chance

No comments:

Post a Comment