ordering categories/sub-categories alphabetically

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

Post Reply
chrismartin
Posts: 4
Joined: Thu Aug 07, 2003 9:53 am

ordering categories/sub-categories alphabetically

Post by chrismartin »

Hi - great program.

Is there a quick way to order categories and sub-categories alphabetically? I tried adjusting the printCategories() function, but it just screwed the listing up.

Any help u could give would be greatly appreciated
Thorsten
Posts: 15564
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

this should work:

Code: Select all

$result = $db->query("SELECT rubrik, titel FROM ".$sqltblpre."faqrubrik WHERE LEFT(rubrik, ".strlen($_REQUEST["rubrik"]).") = '".$_REQUEST["rubrik"]."' AND LENGTH(rubrik) > '".strlen($_REQUEST["rubrik"])."' ORDER BY titel");
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
chrismartin
Posts: 4
Joined: Thu Aug 07, 2003 9:53 am

Post by chrismartin »

thanks for the reply.

Unfortuneatly the code you supplied didnt work. It ordered the results alphabetically, but the category structure was messed up.

This is how it looks at the present:

· Analox Products (0 Entries)
· Analox 9212 (0 Entries)
· Analox 101D2 (0 Entries)
· Analox 3000 Series (0 Entries)
· CO2 Buddy (0 Entries)
· Analox 5 (0 Entries)
· Analox Sub MKIIP (0 Entries)
· Analox Sub MKIIF (0 Entries)
· Analox CAGA (0 Entries)
· Analox 2000s (0 Entries)
· Analox 5s (0 Entries)
· Analox 1371 (0 Entries)
· Analox 1 (0 Entries)
· Analox 3D (0 Entries)
· Analox 1320 (0 Entries)
· Mini O2DII (0 Entries)
· Analox 1300 (0 Entries)
· Analox 100HYP (0 Entries)
· Analox Hyper-Gas (0 Entries)
· Analox O2EII (1 Entries)
· O2 Buddy (0 Entries)
· Analox 1000C (2 Entries)
· Analox 1000 (0 Entries


This is how it looked after your code was inserted:

· Analox 1
· Analox 1000
· Analox 1000C
· Analox 100HYP
· Analox 101D2
· Analox 1300
· Analox 1320
· Analox 1371
· Analox 2000s
· Analox 3000 Series
· Analox 3D
· Analox 5
· Analox 5s
· Analox 9212
· Analox CAGA
· Analox Hyper-Gas
· Analox O2EII
· Analox Sub MKIIF
· Analox Sub MKIIP
· CO2 Buddy
· Mini O2DII
· O2 Buddy

Also, the left side column displaying the category list is unaffected, as is the main area after clicking 'show all categories' (displays is non-alphabetical order).

Sorry for the length of this post - I thought it may help if you could see what output I am getting.

Thanks
chrismartin
Posts: 4
Joined: Thu Aug 07, 2003 9:53 am

Post by chrismartin »

without your code:

Code: Select all

   · Analox 9212
   · Analox 101D2
   · Analox 3000 Series
   · CO2 Buddy
   · Analox 5
   · Analox Sub MKIIP
   · Analox Sub MKIIF
   · Analox CAGA
   · Analox 2000s
   · Analox 5s
   · Analox 1371
   · Analox 1
   · Analox 3D
   · Analox 1320
   · Mini O2DII
   · Analox 1300
   · Analox 100HYP
   · Analox Hyper-Gas
   · Analox O2EII
   · O2 Buddy
   · Analox 1000C
       · Analox 1000
with your code:

Code: Select all

· Analox 1 
    · Analox 1000 
· Analox 1000C 
· Analox 100HYP 
· Analox 101D2 
· Analox 1300 
· Analox 1320 
· Analox 1371 
· Analox 2000s 
· Analox 3000 Series 
· Analox 3D 
· Analox 5 
· Analox 5s 
· Analox 9212 
· Analox CAGA 
· Analox Hyper-Gas 
· Analox O2EII 
· Analox Sub MKIIF 
· Analox Sub MKIIP 
· CO2 Buddy 
· Mini O2DII 
· O2 Buddy 
sorry - forgot to show indentation in first reply!
Thorsten
Posts: 15564
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

sorry for my wrong code, this should work:

Code: Select all

$result = $db->query("SELECT rubrik, titel FROM ".$sqltblpre."faqrubrik WHERE LEFT(rubrik, ".strlen($_REQUEST["rubrik"]).") = '".$_REQUEST["rubrik"]."' AND LENGTH(rubrik) > '".strlen($_REQUEST["rubrik"])."' ORDER BY rubrik, titel");
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Post Reply