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

How to make SQL SELECT 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-12
Networking, Programming and Graphics - Tutorials
Visited: 5939 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
$quety
="select * from table";
$result=mysql_query($query);
?> 
Above example will return you:
ID Name Sex Age
1 John Smith Male 33
2 Barbara Roland Female 28
3 Kate Winston Female 22
4 Peter Trump Male 46
5 Andrea Gilbert Female 37
In next example we will extend the query to more complex and specific query.

This query will return you all male personal, ordered by age and will start from old to young mans.
<?php
$query
="select `id`, `name` from `staff` where `sex`='male' order by `age` desc";
$result=mysql_query($query);
?> 
And the above example will return you:
ID Name Sex Age
4 Peter Trump Male 46
1 John Smith Male 33
Rate this tutorial:                    
Post Comment

Need a specific tutorial? Do not hesitate and submit a request!
Your e-mail: