rhock_95 Posted August 18, 2003 Share Posted August 18, 2003 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 ; Quote Link to comment Share on other sites More sharing options...
Barand Posted August 18, 2003 Share Posted August 18, 2003 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? Quote Link to comment Share on other sites More sharing options...
rhock_95 Posted August 18, 2003 Author Share Posted August 18, 2003 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; } Quote Link to comment Share on other sites More sharing options...
Barand Posted August 19, 2003 Share Posted August 19, 2003 As I said in my last post ..... ORDER BY cat Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.