PHP SQL Where is used to modify or change the structure of table definition based on the condition specified in Where Clause. The PHP SQL Where allows you to update the field based on the condition specified in Where Clause.
Understand with Example
The Tutorial illustrate an example from 'PHP SQL Where'. To grasp the example we create a emp_table whose required fields and datatypes are specified. In the figure below the first figure show before update the table and the second figure show after update the table.
Table: emp_table before update
Table: emp_table after update
The PHP SQL Where starts with the <?php tag and end with ?>. The $ variable con is used to assigned the value of mysql_connect () function that accept the parameter local host, user and password to authenticate the connection between PHP and MySQL database. The die script executed when there is a connection failure between the PHP and MySQL. Once the connection is built successfully, the update query operation is performed to update the table 'emp_name' and set the new value for 'emp_name' to sandeep based on the 'emp_id = 1' condition specified in Where Clause. The While loop is used to execute the code repeatedly based on Boolean condition. The loop fetches the records from table until the condition evaluate to true.
Source Code of update_where.php
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: October 6, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles