Jump to content

Archived

This topic is now archived and is closed to further replies.

rhock_95

sorting by columns not working??

Recommended Posts

hope someone can help me... I have a table (see below) that ai am adding data to OUT side of chronological order...(i.e., categorically by alphabetical order...).... this puts the \"ID\" (auto increment) out of sync alphabetically...

 

My problem when I go back and reset the table order by \"category\"... it is not correct... there will be blocks of \"A\'s\" , \"B\'s\" , \"c\'s\", then more :A\'s\" etc... etc..

 

 

can anyone help me?

 

CREATE TABLE `bus_list` (

`name` varchar(255) NOT NULL default \'\',

`address` varchar(255) NOT NULL default \'\',

`city` varchar(255) NOT NULL default \'\',

`zip` varchar(15) default NULL,

`phone` varchar(40) default NULL,

`www` varchar(255) default NULL,

`notes` text,

`cat` varchar(255) default NULL,

`id` int(11) unsigned NOT NULL auto_increment,

`subcatid` varchar(11) default NULL,

PRIMARY KEY (`id`)

) TYPE=MyISAM AUTO_INCREMENT=1 ;

Share this post


Link to post
Share on other sites

Have you tried

 

[php:1:dc6dc8338d]<?php

$sql = \"SELECT * FROM bus_list ORDER BY cat\";

?>[/php:1:dc6dc8338d]

 

there will be blocks of \"A\'s\" , \"B\'s\" , \"c\'s\", then more :A\'s\" etc... etc..

 

Is that \":A\" actually one of your categories or is it a typo?

Share this post


Link to post
Share on other sites

by \"A\" I meant several categories that begin with the letter \"A\"...

 

the problem is... I have a script that has two drop down menus that are populated by the database... on is \"Citiy\" and the other is \"category\"

 

I really need the category menu to be in exact alphabetical order...?

 

any ideas?

 

 

//get data for city and category

$sql = \'SELECT DISTINCT city FROM bus_list\';

$r = mysql_query($sql) or die(mysql_error());

while($row = mysql_fetch_object($r))

{

$city[] = $row->city;

}

 

$sql = \'SELECT DISTINCT category FROM bus_list\';

$r = mysql_query($sql) or die(mysql_error());

while($row = mysql_fetch_object($r))

{

$category[] = $row->category;

}

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.