<?php if ($my->id) { $database->setQuery("SELECT COUNT(resid) FROM #__res_reservations WHERE userid='".$my->id."'"); $c = (int)$database->loadResult(); if ($c > 0) { //show the link }}?>