query("SELECT * FROM subscribers WHERE telegramID=" . $tg_user['id']); while($subscriber = $query->fetch_assoc()){ $subscriberID = $subscriber['subscriberID']; } $stmt = $mysqli->prepare("INSERT INTO services_subscriber VALUES (NULL,?, ?)"); $stmt->bind_param("ii", $subscriberID, $service); $stmt->execute(); $query = $stmt->get_result(); header("Location: index.php?do=subscriptions"); } if(isset($_GET['remove'])){ $service = $_GET['remove']; $query = $mysqli->query("SELECT * FROM subscribers WHERE telegramID=" . $tg_user['id']); while($subscriber = $query->fetch_assoc()){ $subscriberID = $subscriber['subscriberID']; } $stmt = $mysqli->prepare("DELETE FROM services_subscriber WHERE subscriberIDFK = ? AND serviceIDFK = ?"); $stmt->bind_param("ii", $subscriberID, $service); $stmt->execute(); $query = $stmt->get_result(); header("Location: index.php?do=subscriptions"); } $query = $mysqli->query("SELECT services.id, services.name, subscribers.subscriberID, subscribers.telegramID FROM services LEFT JOIN services_subscriber ON services_subscriber.serviceIDFK = services.id LEFT JOIN subscribers ON services_subscriber.subscriberIDFK = subscribers.subscriberID WHERE subscribers.telegramID =" . $tg_user['id']); if ($query->num_rows){ $timestamp = time(); echo '