Before I start on this things and I would like to inform that I have tried to find in the web, youtube and books and it seems I don't get a clue for what I am exactly trying to do.
The main feature of this page is the following as example:
a MySQL
database in XAMPP
and a HTML
page with PHP
on it.
My PHP
code conects to the DB
and then I have created 3 checkboxes -
- 1 - MOUSE
- 2 - Dog
- 3 - Tiger
( This things will be the checkboxes options. with an input button (to retrieve the info)
If you select checkbox 1 the PHP
code should call the Table
animals and give you as result MOUSE
But I want that if user select Mouse and DOG, retrieve the fastest animal in this case will be Checkbox 2: Or if user select 3 of them gives you as result number 3 (Tiger.)
I being watching tutorials and so on an the retrieve I got it but only for the HTML part even I can connect to the DB, the questions will be
How do I set first the Checkboxes? How do I call the database to each of this checkboxes? Which comparison statement do I need to use in order to give me the desired logic?
html>
<head>
<title>Fastest animal selection</title>
</head>
<body>
<div class="container box">
<h3 align="center">Fastest animal selection</h3><br />
<h4>Please Select your Animal.</h4><br />
<form method="post">
<p><input type="checkbox" name="animal[]" value="MOUSE" /> MOUSE</p>
<p><input type="checkbox" name="animal[]" value="DOG" /> DOG</p>
<p><input type="checkbox" name="animal[]" value="TIGER" /> TIGER</p>
<p><input type="submit" name="submit" class="btn btn-info" value="Get fastest animal" /></p>
</form>
<?php
if(isset($_POST["submit"]))
{
$for_query = '';
if(!empty($_POST["animal"]))
{
foreach($_POST["animal"] as $animal)
{
echo '<p>'.$animal.'</P>';
}
}
else
{
echo "<label class='text-danger'>* Please select at least one animal.</label>";
}
}
?>
</div>
</body>
</html>
</div>