Networking, Programming and Graphics - Tutorials
ONLINEHOWTO.net Tutorials Category

How to make SQL UPDATE query

Type: Code Networking, Programming and Graphics - Tutorials
Networking, Programming and Graphics - Tutorials
Level: Beginner Networking, Programming and Graphics - Tutorials 
Networking, Programming and Graphics - Tutorials
Date: 2007-Mar-16
Networking, Programming and Graphics - Tutorials
Visited: 5811 times
Networking, Programming and Graphics - Tutorials
Rating: Networking, Programming and Graphics - Tutorials
Networking, Programming and Graphics - Tutorials
Published: 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:                    
Post Comment

    • ( henrik [ at ] hornhaver . dk ),

      posted on 2010-Jun-06 | 10:04:55 AM
      nope
    • ( henrik [ at ] hornhaver . dk ),

      posted on 2010-Jun-06 | 10:05:37 AM
      ooo
Need a specific tutorial? Do not hesitate and submit a request!
Your e-mail: