Go Back   Wiki NewForum > Career Forum (Documents/Tutorials/Advice) > Tech Forum & Tutorial > PHP Forum & Tutorial

PHP Forum & Tutorial PHP Tutorial, Codes, Examples & Full End-To-End Process

Reply
Views: 938 Source: CNN18.com, India-Forums, TellyChakkar, India, Times of India, Youtube, BollywoodLife, Rediff  
Thread Tools Rate Thread Display Modes
  #1  
Old 05-04-2009, 05:51 PM
welcomewiki welcomewiki is offline
Member
 
Join Date:
Dec 2008
Location:
India
Posts: 39,083
Default PHP MySQL The Where Clause

he WHERE clause is used to filter records. The WHERE clause

The WHERE clause is used to extract only those records that fulfill a specified criterion.
Syntax

SELECT column_name(s)
FROM table_name
WHERE column_name operator value



To learn more about SQL, please visit our SQL tutorial.


To get PHP to execute the statement above we must use the mysql_query() function. This function is used to send a query or command to a MySQL connection.
Example

The following example selects all rows from the "Persons" table where "FirstName='Peter':






$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
WHERE FirstName='Peter'");

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

?>



The output of the code above will be:
Peter Griffin

Ads
Reply With Quote
Reply

New topics in PHP Forum & Tutorial

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump


Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
asp web stats