Wednesday, December 9, 2009

12:43 PM
In mysql, the SELECT command is used to retrieving data from the database.  We can get the single value or a array of values from the database.
The values are getting from the database by using the following code

$output=mysql_query("SELECT * From table_name");

Here all the results are stored in the variable "output"

If we want to retrieve array of values from the above result,  then we use the following code

$output1 = mysql_fetch_array($result);


$con = mysql_connect("localhost","peter","abc123");
if (!$con)
  die('Could not connect: ' . mysql_error());

mysql_select_db("my_db", $con);

$result = mysql_query("SELECT * FROM Persons");

while($row = mysql_fetch_array($result))
  echo $row['FirstName'] . " " . $row['LastName'];
  echo "