$indexexists = checkforindex(groupby); if ($indexexists) { $sql = "ALTER TABLE `" . table_pageviews . "` DROP INDEX `groupby`;"; $db->query($sql); }