Veronica's Query Demo via POST

Note this DEMO passes a variable (and it's value) via a POST ternary operation. In other words, the name of the variable and it's value is being passed through POST form.

This could be used to give users an option to flip through choices. The id in this example refers to a category of furniture for sale.

Category: beds

ID = 0


 

CODE FOLLOWS

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

// set error reporting to all
error_reporting(E_ALL);

// get the id from a POST operation via POST ternary operator
$id = isset($_POST['id']) ? $_POST['id'] : 0;

// create items array for shopping demonstration
$items = array("beds","bookshelves","chairs","coffee tables","desks","dining chairs",
    
"dining tables","dressers","end tables","kids furniture","recliners","sofas");

?>

<h1>Veronica's Query Demo via POST</h1>

<p>
    Note this DEMO passes a variable (and it's value) via a POST ternary operation.
    In other words, the name of the variable and it's value is being passed
    through POST form.
</p>
<p>
    This could be used to give users an option to flip through choices.
    The id in this example refers to a category of furniture for sale.
</p>

<p>Category:
    <?php
    
if ($id > -&& $id count($items))
    {
        echo(
$items[$id]");
    } else
    {
        echo(
" N/A");
    }
    echo(
"<br><br>ID = $id");
    
?>
</p>

<form action="" method="POST">

    <input type="hidden" name="id" value="<?php echo($id 1); ?>">
    <input type="submit" name="submit" value=" DECREASE Number ">

</form>

<br>

<form action="" method="POST">

    <input type="hidden" name="id" value="<?php echo($id 1); ?>">
    <input type="submit" name="submit" value=" INCREASE Number ">

</form>

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