PHP SQL Query not working correctly

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
http://new.monmouthchineseschool.com/curriculum/cantonese/textbook.php

if you take a look at 'C1'
一 十 十一 十二 十三 二 三 四 五 六 七 八 九
that is how all the links look like.
this is the mysql db for that class
Code:
CREATE TABLE IF NOT EXISTS `mon_textbook` (
  `id` int(11) NOT NULL auto_increment,
  `class` varchar(255) NOT NULL,
  `ch` varchar(255) NOT NULL,
  `sTitle` varchar(255) NOT NULL,
  `fTitle` varchar(255) NOT NULL,
  `text` longtext NOT NULL,
  UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=117 ;

--
-- Dumping data for table `mon_textbook`
--

INSERT INTO `mon_textbook` (`id`, `class`, `ch`, `sTitle`, `fTitle`, `text`) VALUES
(14, 'C1', '1', '一', '第一課', ''),
(15, 'C1', '2', '二', '第二課', ''),
(16, 'C1', '3', '三', '第三課', ''),
(17, 'C1', '4', '四', '第四課', ''),
(18, 'C1', '5', '五', '第五課', ''),
(19, 'C1', '6', '六', '第六課', ''),
(20, 'C1', '7', '七', '第七課', ''),
(21, 'C1', '8', '八', '第八課', ''),
(22, 'C1', '9', '九', '第九課', ''),
(23, 'C1', '10', '十', '第十課', ''),
(24, 'C1', '11', '十一', '第十一課', ''),
(25, 'C1', '12', '十二', '第十二課', ''),
(26, 'C1', '13', '十三', '第十三課', '');
the sql query that calls it
PHP:
$sql = 'SELECT * FROM '.dbPre.'textbook WHERE `class`="'.$textbookClass[$ii].'" ORDER BY `ch` ASC';

instead of looking like how it is above, it should look like this
一 二 三 四 五 六 七 八 九 十 十一 十二 十三



Edit:
I got it fixed.
http://stackoverflow.com/questions/2215535/howcome-my-sql-query-is-not-sorting-the-column
`ch` needed to be an integer type
 
Last edited:
Top