php mysql help needed

Discussion in 'PHP' started by MrPJH, Jan 7, 2011.

  1. #1
    i have some categories of my website i want to show number of inputs in specific category it is smiler when we see a link directory on category name we usually see how many links are in this category or regarding this forum from main we can see how many threads and posts a forum has please help how to do this math
    my site is in PHP and database is SQL

    regards
     
    MrPJH, Jan 7, 2011 IP
  2. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
    #2
    Adapt to this :
    
    $result = mysql_query("SELECT COUNT(*) AS nr FROM category_table WHERE category_id = NUMBER");
    $row = mysql_fetch_array($result);
    echo $row['nr'];
    
    PHP:
     
    tvoodoo, Jan 7, 2011 IP
    MrPJH likes this.
  3. MrPJH

    MrPJH Well-Known Member

    Messages:
    1,066
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    155
    #3
    thanks tvoodoo it gives this error
    
    Notice: Undefined index: nr in /usr/home/user/domains/domian.com/public_html/categories.php on line 30
    Code (markup):
    how ever this worked fine for me
    
    $result = mysql_query("SELECT COUNT(*) FROM category_table WHERE category_id = NUMBER");
    $row = mysql_fetch_array($result,MYSQL_BOTH);
    echo $row['0'];
    
    Code (markup):
    anyway thanks for your great help
     
    Last edited: Jan 7, 2011
    MrPJH, Jan 7, 2011 IP
  4. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
    #4
    you should have replaced category_table with your table name and the value NUMBER with a existing category id number !
     
    tvoodoo, Jan 7, 2011 IP