public function setLike() { $user = new CurrentUser(); if ($user->isLoggedIn()) { $alreadyLiked = false; while ($row = mysqli_fetch_array($this->result)) { if ($row['UserID'] == $user->getCookieID()) { $alreadyLiked = true; } } if ($alreadyLiked) { return; } else { self::DBConnect("likes", $this->ID, $user->getCookieID()); } } else { echo "not logged in"; } }