SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    only display category once

    Hi guys

    I'm calling categories from my knowledge table


    problem is is i only want the category to display once on this page

    http://www.notexperienced.co.uk/support.php


    as you can see Managing Your CV displays twice





    PHP Code:
    <? 


    $sql 
    = ("select * from knowledge WHERE type ='Jobseeker' ORDER BY category ASC");






                  
    $result mysql_query ($sql);

                  while (
    $row mysql_fetch_array($result))
                  {



      
    $title $row["category"];

     


    echo 
    "<a href=\"viewsupport.php?category=$title&type=Jobseeker\">$title</a><br>";



      }






    ?>

    How can i change it so it only displays once

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,269
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)

    only one

    If you only want 1 to show try
    PHP Code:
    $sql = ("select * from knowledge WHERE type ='Jobseeker' ORDER BY category ASC LIMIT 1");
                  
    $result mysql_query ($sql); 
                  if (
    $row mysql_fetch_array($result)) 
                  { 

  3. #3
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried that but didnt work

  4. #4
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    sql = ("select DISTINCT category from knowledge WHERE type ='Jobseeker' ORDER BY category ASC"); 
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  5. #5
    SitePoint Zealot darksystem's Avatar
    Join Date
    Jan 2005
    Location
    Fayettville, North Carolina
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can even try this

    $sql = ("select * from knowledge WHERE type ='Jobseeker' ORDER BY category ASC");

    $row = mysql_fetch_array($sql);

    echo "<a href=\"viewsupport.php?category=$row['category']&type=Jobseeker\">$title</a><br>";
    Ebay API, OSC/CRE/OscMax/ZenCart/SEO Services
    Lucki Multimedia - Email

  6. #6
    SitePoint Evangelist optl's Avatar
    Join Date
    Oct 2004
    Location
    Washington DC
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you only want to show one result do this:
    Quote Originally Posted by darksystem View Post
    you can even try this

    $sql = ("select * from knowledge WHERE type ='Jobseeker' ORDER BY category ASC");

    $row = mysql_fetch_array($sql);

    echo "<a href=\"viewsupport.php?category=$row['category']&type=Jobseeker\">$title</a><br>";
    If you want each category to only show once then use the DISTINCT category trick posted above.
    For the phrase "Bethesda home architect", my clients
    websites occupy 6 of the first 8 results
    on the 1st page of Google. My Secret SEO Strategy Revealed

  7. #7
    SitePoint Zealot darksystem's Avatar
    Join Date
    Jan 2005
    Location
    Fayettville, North Carolina
    Posts
    184
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Agreed - (if he just wants to display the category once)
    Ebay API, OSC/CRE/OscMax/ZenCart/SEO Services
    Lucki Multimedia - Email


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •