I have a page on poems. As part of the page I wish to put text such as "this is a collection of poems on......". Where the ..... is, I want to insert the category name.

I am using a mysql d/b (called poems) split into various tables. The table that the cat id (which is a number) and cat name is in is called categories, then split into catid and catname. I was able to get it to show the catid (never been able to get it to show the catname. The page is calling the database etc correctly but of course have I not lost my original "success" . So back to square one. Can anyone give me some pointers?

    Here's a basic way to do that. There's a lot left out here (database connection, error checking, the $id variable is assumed to be set in this script, etc), but you should get the idea.

    
    $query = mysql_query("SELECT catname FROM poems WHERE catid='".$id."'") or die(mysql_error());
    
    $row = mysql_fetch_assoc($query);
    
    echo "This is a collection of poems on " . $row["catname"] . "<br />\n";
    
    
      Write a Reply...