prepare("INSERT INTO services_subscriber (subscriberIDFK, serviceIDFK) VALUES (?, ?)"); $stmt->bind_param("ii", $userID, $service); $stmt->execute(); $query = $stmt->get_result(); } public function remove($userID, $service) { global $mysqli; $stmt = $mysqli->prepare("DELETE FROM services_subscriber WHERE subscriberIDFK = ? AND serviceIDFK = ?"); $stmt->bind_param("ii", $userID, $service); $stmt->execute(); $query = $stmt->get_result(); } function render_subscribed_services($typeID, $subscriberID, $userID, $token) { global $mysqli; $stmt = $mysqli->prepare("SELECT services.id, services.name, subscribers.subscriberID, subscribers.userID, subscribers.token FROM services LEFT JOIN services_subscriber ON services_subscriber.serviceIDFK = services.id LEFT JOIN subscribers ON services_subscriber.subscriberIDFK = subscribers.subscriberID WHERE subscribers.typeID = ? AND subscribers.subscriberID = ?"); $stmt->bind_param("ii", $typeID, $subscriberID); $stmt->execute(); $query = $stmt->get_result(); $timestamp = time(); $strNotifyType = _('E-mail Notification subscription'); if ( $typeID == 1 ) { $strNotifyType = _('Telegram Notification subscription'); } ?>
' . _("Your subscriptions") . ""; echo '
'; $subs = array(); // Will be used to hold IDs of services already selected if ($query->num_rows){ while($result = $query->fetch_assoc()) { echo ' ' . $result['name'] . ''; $subs[] = $result['id']; } } else { echo '
'._("You do not currently subscribe to any services. Please add services from the list below.").'
'; } echo "
"; echo '

' . _("Add new subscription") . '

'; // Prepare to query for unselect services. If none are selected, query for all $subsExp = null; if (count($subs) > 0 ) { $subsExp = 'NOT IN ('. implode(",", $subs) .')'; } $query = $mysqli->query("SELECT services.id, services.name from services WHERE services.id $subsExp"); echo '
'; if ($query->num_rows){ while($result = $query->fetch_assoc()){ echo ' ' . $result['name'] . ''; } } else { echo '
'._("No further services available for subscriptions.").'
'; } echo '
'; } }