SQL joins help needed

    Date: 03/23/06 (PHP Community)    Keywords: mysql, sql

    Need some help with this - I made an external table for the categories in my blog, and now I want to join the blog and the blog_cat table, so it selects the name from the cat table where the category equals the catID. *Something* works already, but it just keeps selecting only one category one, instead of the equal one it should be selecting. I'm pretty much a noob =_=


    $sql = "SELECT * FROM $tableblog ORDER BY timestamp DESC LIMIT 5";
    $result = mysql_query($sql) or
    print ("Unable to select data.
    " . $sql . "
    " . mysql_error());
    while ($row = mysql_fetch_array($result))
    {
    $date = date("l, F dS, Y - h:ia",$row["timestamp"]);
    $category = $row["category"];
    $entry = $row["entry"];
    $id = $row["id"];
    // ....

    $result3 = mysql_query("SELECT category, catID, catname FROM $tableblog, $tableblogcat WHERE category=catID") or
    print ("Unable to select data.
    " . $sql . "
    " . mysql_error());
    while ($row = mysql_fetch_array($result3))
    {
    $catID = $row["catID"];
    $catname = $row["catname"];
    }

    print "<.a href=\"categories.php?c=$category\">$catname";
    }

    Source: http://community.livejournal.com/php/429875.html

« Serialized objects || recursive query »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home