12, October 2008

out of order DB response - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  Databases  >  MySQL
Topic: out of order DB response
« previous next »
Pages: [1] Print

Author Topic: out of order DB response  (Read 1008 times)
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« on: Aug 22, 2006, 05:48:16 AM »

when i run this code, it lists the values out of order..

Code:
<?php

//Top 10 C-pts
$result dbquery("SELECT user_name, user_clanrank, user_id, user_cpts 
FROM "
.$db_prefix."users 
ORDER BY user_cpts 
DESC LIMIT 0,10
"
);
echo "<table width='100%' cellpadding='0' cellspacing='1' border='0' class='tbl'>";
if (dbrows($result)!=0) {
while ($data=dbarray($result)) {
include BASEDIR."colors2.php";
echo "<tr>
<td class='tbl2' align='left'><a style='color: $mm_color' href='"
.BASEDIR."profile.php?lookup=".$data['user_id']."'>
"
.$data['user_name']."</a></td>
<td class='tbl2' align='right'>"
.$data['user_cpts']."</td>
</tr>"
;
}
}
echo "</table>";
//

?>

also, simply running this DB query will give me same results:

Code:
<?php

dbquery
("SELECT user_name, user_clanrank, user_id, user_cpts 
FROM fusion_users 
ORDER BY user_cpts 
DESC LIMIT 0,10"
)?>

i receive this order of results, 91, 60, 60, 60, 50, 50, 50, 250. 250 shold be first Sad
« Last Edit: Aug 22, 2006, 05:58:04 AM by Meth0d »

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6349
38918 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Aug 22, 2006, 09:08:29 AM »

what is the datatype of "user_cpts"?

try... ORDER BY user_cpts*1 DESC...


Last blog : Upload images for usage in TinyMCE
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #2 on: Aug 22, 2006, 03:41:37 PM »

nvm, it was set as VARCHAR(255) so i changed it to BIGINT(9) and it orders it fine, strange

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6349
38918 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Aug 22, 2006, 04:13:37 PM »

nvm, it was set as VARCHAR(255) so i changed it to BIGINT(9) and it orders it fine, strange
is not strange, if you want order by a number you need a number and not a string Wink


Last blog : Upload images for usage in TinyMCE
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=3749
Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  Databases  >  MySQL
Topic: out of order DB response
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Oct 12, 2008, 12:18:09 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 36.918
Total Topics: 7.558
Total Members: 4.151
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: 22gigs

15 Guests, 3 Users online :

10 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.