Networking, Programming and Graphics Tutorials

How to make SQL UPDATE query [1/1]

Type: Code Networking, Programming and Graphics Tutorials
How to make SQL UPDATE query
Level: Beginner Networking, Programming and Graphics Tutorials 
How to make SQL UPDATE query
Date: 2007-Mar-16
How to make SQL UPDATE query
Visited: 2274 times
How to make SQL UPDATE query
Rating: How to make SQL UPDATE query
How to make SQL UPDATE query
Author: Ivory Morhuld

This tutorial will show you how to use MySQL querys to database in your PHP scripts.

mysql_query(query, [link_identifier])


mysql_query() sends a query to the currently active database on the server that's associated with the specified link identifier. If link_identifier isn't specified, the last opened link is assumed. If no link is open, the function tries to establish a link as if mysql_connect() was called with no arguments, and use it.

In next examples we will teach you how to make more querys.

<?php
$query
="update table set field1='value1', field2='value2', fieldN='valueN'";
$result=mysql_query($query);
?> 
In next example we will extend the query to more complex and specific query.

This query will update date to current data, field1 will be equal to filed2 and field3 will be increased with 21 in all rows where sex equal to male, and age more that 21.

<?php
$query
="update table set date=now(), field1=field2, field3=field3+21 where sex='male' and age>='21'";
$result=mysql_query($query);
?> 
Rate this tutorial:                    
Networking, Programming and Graphics Tutorials - How to make SQL UPDATE query [1/1] - Networking, Programming and Graphics Tutorials

Need a specific tutorial? Do not hesitate and submit a request!
Related Tags: how to make update query in php  how to make an update query  HOW TO MAKE AN UPDATE QUERY  how to make an update query in php  usings select query inside update query  Select query inside update query  update date in query update  php select query update query  query update mysql $query  create an update query from a query