Don Alexander Eckford's Query Demo via GET

Note this DEMO passes a variable (and its value) via a GET ternary operation. In other words, the name of the variable and its value is being passed through the URL. There is no form involved.

Please note the string "?id=5" in the URL.

ID = 5

DECREASE ID     INCREASE ID      
 

CODE FOLLOWS

<?php
// Include the header file
include('includes/header.php');

// Start a session (if you want to use session management)
session_start();

// Set error reporting to all (for development)
error_reporting(E_ALL);
ini_set('display_errors'1); // Ensure errors are displayed during development

// Get the 'id' from the URL, sanitize it using intval and set a default value if not provided
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;

// Prevent negative IDs if they are not valid
if ($id 0) {
    
$id 0;
}

// Store the ID in session (if relevant for your use case)
$_SESSION['id'] = $id;
?>

<h1>Don Alexander Eckford's Query Demo via GET</h1>

<p>
    Note this DEMO passes a variable (and its value) via a GET ternary operation.
    In other words, the name of the variable and its value is being passed
    through the URL. There is no form involved.
</p>

<p>
    Please note the string "?id=<?php echo htmlspecialchars($id); ?>" in the URL.
</p>

<p>
    ID = <?php echo htmlspecialchars($id); ?>
</p>

<a href="query_get.php?id=<?php echo($id 1); ?>"> DECREASE ID </a> &nbsp; &nbsp;
<a href="query_get.php?id=<?php echo($id 1); ?>"> INCREASE ID </a> &nbsp;  &nbsp; &nbsp;

<?php
// Include the footer file
include('includes/footer.php');
?>