SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is my categories page:

    <html><head><title>Categories</title></head><body>
    <br><Br><br>

    <?php
    include("articles.inc");
    mysql_select_db('petesmc_articles');

    $write = mysql_query("SELECT ID, Cat, Description FROM category");
    if (!$write) {
    echo("<P>Error retrieving cateogry from database!<BR>".
    "Error: " . mysql_error());
    exit();
    }

    while ($cat= mysql_fetch_array($write)) {
    $id = $cat["ID"];
    $name = $cat["Cat"];
    $description = $cat["Description"];
    echo("<p><a href='subcats.php?id=$id'>$name</a> " .
    "</p><br><font size='1'>$description</font>");
    }
    ?>

    </body></html>


    My question is, what would i write on the page called subcats? AS you can see, i have a link to it down the bottom. In table subcateogry i have the fields:

    ID, CID, SubCat, Description

    CID is category ID, which it belongs to.

    So how would i show all the subcateogories within a selected category?
    <Edited by petesmc on 01-04-2001 at 10:53 AM>

  2. #2
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To just plain list them out, something like this would work:

    $dbh = mysql_connect(.....);
    mysql_select_db("DB_name");
    $qry = mysql_query("select * from subcategory where CID=$id");
    while($results = mysql_fetch_row($qry)) {
    do_stuff(with==results);
    }


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
  •