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);
Example:
$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 "
";
}
mysql_close($con);
Home
»
data
»
database
»
get
»
mysql
»
PHP
»
retrieve
»
select
» Retrieving data from the MYSQL database using PHP
Wednesday, December 9, 2009
Related Posts
Facebook Like Infinite Scroll Using PHP, jQuery, Ajax and MySQL
23 September 2015Learnphp4AngularJS Insert Update Delete with PHP and MySQL
14 October 2015Learnphp8Facebook like Button Application Using PHP, MySQL, jQuery and Ajax
24 June 2015Learnphp0Instant Search With Pagination in PHP, MySQL, jQuery and Ajax
21 June 2015Learnphp0
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment