Your question is a little lacking in detail, however I believe you want to take the items that made up a previous order, and show the category of each product?
This is the code that would do all of that in a loop - considering you've not said what template you want it to be in, if it's in the account area, or in an email or the order confirmation screen etc, you'll have to figure out the bits you need and the bits you don't:
$order = Mage::getModel('sales/order')->loadByIncrementId(500001); //Load a specific order
$items = $order->getAllVisibleItems(); // Get the items that make up this order
foreach ($items as $item){
$categoryIds = $item->getProduct()->getCategoryIds();
$bottomCategory = Mage::getModel('catalog/category')->load(end($categoryIds)); //We only want one category, so get the very last one
echo $item->getSku() . " has a category of " . $bottomCategory->getName() . "<br />" ;
}