如何使用PHP和MySQL将URL类别编号更改为单词?

I bought an iPhone wallpaper gallery PHP script a year ago, and it has been running great. I've been slowly learning PHP and MySQL by doing little tweaks here and there.

To view a category, the URL is www.example.com/index.php?catid=27, and I want to change it to www.example.com/index.php?catid=apple for SEO reasons. I know I can futher tidy up the URL with .htaccess but I just want to get this word slug to begin with.

This is the code (inside index.php) that I think generates the category pages:

if (($_REQUEST['catid']) && ($_REQUEST['catid'] > 1)) {
        $catid = $_REQUEST['catid'];
        if (is_numeric($catid)) {
            $tempitemarray = $myitems->getItemsByCategory($catid);
            $catnav = "&catid=" . $catid;
            $tempcat = new Category();
            $tempcat->getCategory($catid);
            $maintitle = "<h1>" . $tempcat->getCategoryName() . " " . $itemplural . "</h1>";
        }

That code calls another PHP page called itemList.php, and inside that page I found this code:

public function getItemsByCategory($catid) {
        $this->retrieveSQL = "select * from items i, item_category_lookup l where livedate < '" . $this->currentdate . "' and  i.active = " . $this->showApproved . " and l.categoryid = $catid and i.id = l.itemid order by i.livedate desc limit " . $this->startRow . "," . $this->numRows;
        $this->countSQL = "select * from items i, item_category_lookup l where livedate < '" . $this->currentdate . "' and  i.active = " . $this->showApproved . " and l.categoryid = $catid and i.id = l.itemid";
        $this->retrieveItems();
        return $this->items;
    }

This is the 'items' table:

    id | itemname | itemdec | itemkeywords | createdate | viewcount | active | rating | livedate | sourcedesc | sourceurl
-----------------------------------
    64 | Apple Logo

This is the 'item_category_lookup' table:

categoryid | itemid
-------------------------
27         | 64

This is the 'category' table below. It's not called in the query above but does have the actual category names. How would I implement it?

id | categoryid
------------------
27 | Apple

You might change the SQL of $this->retrieveSQL = ... into

if (!is_number($catid)) {
        $this->retrieveSQL = "select * from items i, item_category_lookup l, category j where livedate < '" . $this->currentdate . "' and  i.active = " . $this->showApproved . " and i.id = l.itemid and j.id = l.categroyid and j.categoryid = "$catid" order by i.livedate desc limit " . $this->startRow . "," . $this->numRows;
}

Try this: URL example: www.example.com/index.php?catid=27-apple

if ( isset( $_REQUEST['catid'] ) ) {
    $catSEO = explode( '-', $_REQUEST['catid'] );
}
$catid = is_numeric( $catSEO[0] ) ? $catSEO:0;