ascending order not ascending!
ascending order not ascending!
ascending order not ascending!
ascending order not ascending!
ascending order not ascending!
ascending order not ascending! ascending order not ascending! ascending order not ascending! ascending order not ascending! ascending order not ascending! ascending order not ascending! ascending order not ascending! ascending order not ascending!
ascending order not ascending! ascending order not ascending!
ascending order not ascending!
Go Back  Xtreme Visual Basic Talk > > > ascending order not ascending!


Reply
 
Thread Tools Display Modes
  #1  
Old 06-05-2012, 05:18 AM
starmanMike starmanMike is offline
Junior Contributor
 
Join Date: Oct 2005
Location: near Norwich, UK
Posts: 257
Default ascending order not ascending!


Hi,
I have a page with two dropdown boxes on. Each is populated dynamically from a database. They both work fine in that respect, but one (for some reason) refuses to be strictly alphabetical, choosing to start at F rather than A, though it is sort of alphabetical! Anyway, I have attached a screen capture of the offender, and here is the relevant code -
(this first section is the very first thing in the page)
Code:
<?php
include('connection.inc.php');
$conn = dbconnect('pubquery');
$sql="SELECT distinct region FROM clubs order by region";
$newsql="SELECT distinct styletype FROM styles order by styletype";
$result=mysql_query($sql,$conn);
$newresult=mysql_query($newsql,$conn);
?>
And this is the relevant section of the page:
Code:
<?php
echo "<form action='allsearch.php' method='post'><select name='style'>\n";
while ($row = mysql_fetch_assoc($newresult))
{
	extract($row);
	echo "<option value='$styletype'>$styletype\n";
}
echo "</select>\n";
echo "<input type='submit' value='search styles' name='submitbutton'></form>\n";
?>
The other select box (partly hidden in the screenshot) works fine alphabetically.
Attached Images
File Type: gif MAFCUKscreen.gif (30.3 KB, 12 views)
Reply With Quote
  #2  
Old 07-25-2012, 10:25 PM
MikeJ's Avatar
MikeJascending order not ascending! MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,747
Default

You may have figured it out by now, but I'd recommend checking the actual value of those fields. There could be some random ASCII/Unicode characters at the front of those strings, which cause the sort to put them in that odd order. However, the browser doesn't display them... so you get this out of order behavior!

Have you checked your input to see if it's been sanitized?
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
  #3  
Old 07-28-2012, 08:11 AM
starmanMike starmanMike is offline
Junior Contributor
 
Join Date: Oct 2005
Location: near Norwich, UK
Posts: 257
Default

As one Mike to another, many thanks. Your hint was correct - turns out that those first few all had initial spaces, evidently from user input. My fault (or should I say mea culpa?) - I should have cleaned up the input first!
Vale,
Mike.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
ascending order not ascending!
ascending order not ascending!
ascending order not ascending! ascending order not ascending!
ascending order not ascending!
ascending order not ascending!
ascending order not ascending! ascending order not ascending! ascending order not ascending! ascending order not ascending! ascending order not ascending! ascending order not ascending! ascending order not ascending!
ascending order not ascending!
ascending order not ascending!
 
ascending order not ascending!
ascending order not ascending!
 
-->