Forum Moderators: coopster

Message Too Old, No Replies

sort list in menu

         

Why_not

8:13 am on Jun 2, 2008 (gmt 0)

10+ Year Member



i have code for add cat + subcat . but until show in menu not trim . and no sort by name & id !
<select name="CATEGORY">
<option selected>
<?php if ($_POST == $nil) echo $_SESSION[CATEGORY]; else echo $_POST[CATEGORY]; ?>
</option>
<option></option>
<?PHP

$SQLcat = "SELECT * from CATEGORIES ORDER BY TITLE ASC";
$resultcat = @mysql_query( $SQLcat); while( $rowcat = @mysql_fetch_array( $resultcat ) ) {

$SQLc1 = "SELECT * from CATEGORIES WHERE ID = '$rowcat[CATEGORY]'";
$resultc1 = @mysql_query( $SQLc1 );
$rowc1 = @mysql_fetch_array( $resultc1 );
//---------------------------------------
?>
<option value = "<?php echo "$rowcat[ID]"; ?>">
<?php echo "$rowcat[TITLE]"; if ($rowc1[TITLE] != $nil) echo " :: $rowc1[TITLE]"; ?>
</option></select>
this code show all cat and all subcat in menu but sort by name for all id
NOTE : if cat or subcat have id ! Example :
Example is cat ! example 2 example 3 example 8 is subcat !
ExampleL is cat ! so 1 so 2 so 3 is sub cat !
until show in menu sort by name ! how to edit this code for sort by this idea :

Example
Example 2
Example 3
Example 8

ExampleL
so 1
so 2
so 3
. . . . . . .
This menu for search site by category .
thanks !

[edited by: Why_not at 8:45 am (utc) on June 2, 2008]

jatar_k

4:58 pm on Jun 2, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I posted some code in a recent thread that may apply

[webmasterworld.com...]