URL: http://phpforms.net/tutorial/tutorial.html
The WHERE clause is used for extracting only those records that fulfill a specified criterion. If you wanted to select only certain entries of your table, then you would use the keyword WHERE. WHERE lets you specify requirements that entries must meet in order to be returned in the MySQL result. Those entries that do not pass the test will be left out. To get PHP to execute the statement above you must use the mysql_query() function. This function is used to send a query or command to a MySQL connection. The following example selects all rows from the Persons table where FirstName='Peter':
<?php $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 "<br />"; } ?>
You need to login to post a comment.
