public function getName($table, $id) { $sql = sprintf("SELECT * FROM %s WHERE id=%s LIMIT 1", $table, $id); $result = $this->db->query($sql); if ($result === true) { $row = $result->fetch_assoc($result); return $row['name']; } else return ''; }