Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
sorting selected data
Old 07-05-2006, 02:25 PM sorting selected data
Junior Talker

Posts: 1
Name: slaven
Trades: 0
hello,

I have a script that retrieves data from a database. Now I want to sort these informations by name, date etc... So, the question is how can i sort already selected data?

tnx

my script for selecting:

HTML Code:
 
$query = "SELECT name, user, city, date from USERS order by name ASC";
$result = mysql_query($query);
if (mysql_num_rows($result) < 1){
echo "No results";
} else { 
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "{$row['name']}";
echo "{$row['user']}";
}
}
aluviana is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-05-2006, 09:28 PM Re: sorting selected data
Webmaster Talker

Posts: 626
Trades: 0
Using ORDER BY in $query automatically sorts the results for you. if you want to have the results sorted by more than just the name, add the extra columns to it.

Example, ORDER BY name, date, city ASC
jim.thornton is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to sorting selected data
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09486 seconds with 12 queries