Activity Stream
48,167 MEMBERS
6921 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 3 of 3

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1.     
    #1
    Member
    Website's:
    imdber.org justpaste.me

    Red face List category ID's

    I want to list all the categories in a page. Each posts have a column with their corresponding category id (numerical). Now how do i list all the categories in a page?

    PHP Code: 
    $db mysql_connect(HOST,UNAME,PASS);
    mysql_select_db(DBNAME);
    $query mysql_query("select * from POSTS");
    while(
    $row mysql_fetch_object($query)){
        switch(
    $row->category){
        case 
    1: echo 'Category A';break;
        case 
    2: echo 'Category B';break;
        case 
    3: echo 'Category C';break;
        case 
    4: echo 'Category D';break;
        
    case5: echo 'Category E';break;
        default: echo 
    'Uncategorized';

    unfortunately this code displays the category everytime it exists
    Apathetic Reviewed by Apathetic on . List category ID's I want to list all the categories in a page. Each posts have a column with their corresponding category id (numerical). Now how do i list all the categories in a page? $db = mysql_connect(HOST,UNAME,PASS); mysql_select_db(DBNAME); $query = mysql_query("select * from POSTS"); while($row = mysql_fetch_object($query)){ switch($row->category){ case 1: echo 'Category A';break; case 2: echo 'Category B';break; case 3: echo 'Category C';break; Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    Website's:
    imdber.org justpaste.me
    WOoooooPPPzzzz:

    PHP Code: 
    select distinct category from posts 

  4.     
    #3
    Member
    Website's:
    wscripts.net damnlolscript.com lulzjet.com
    you can try
    PHP Code: 
    $query mysql_query("select * from POSTS group by category"); 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Category List Help
    By shahzadali55 in forum Webmaster Discussion
    Replies: 5
    Last Post: 28th Aug 2012, 08:04 AM
  2. Different css for different category.
    By r00ts in forum Wordpress
    Replies: 1
    Last Post: 1st May 2012, 11:11 AM
  3. Category list in header wordpress
    By samipk in forum Technical Help Desk Support
    Replies: 6
    Last Post: 9th Jun 2011, 04:47 AM
  4. [Datalife Engine] How to change category list order?
    By Divvy in forum Webmaster Discussion
    Replies: 10
    Last Post: 30th Apr 2011, 11:10 PM
  5. Replies: 23
    Last Post: 3rd Jul 2009, 04:07 AM

Tags for this Thread

BE SOCIAL