jeudi 29 septembre 2016

advanced sql statement executing checkbox checked

I have in my html code a checkbox and a submit button :

<form action="checkboxes.php" method="post">
    <input type="checkbox" name="checkbox1" value="Yes">4K</input>
    <input type="submit" name="formSubmit" value="Submit" ></input>
</form>

And in my php i have a file "config.php" that his function is to connect to my database :

<?php
/* Database connection */

$sDbHost = 'localhost';
$sDbName = 'testowanie';
$sDbUser = 'root';
$sDbPwd = '';
$dbcon = mysqli_connect ($sDbHost, $sDbUser, $sDbPwd, $sDbName);
?>

And a second php file :

<?php
include('config.php');

$sqlget = "SELECT * FROM monitory";
$sqldata = mysqli_query($dbcon, $sqlget)or die("Can't connect to the database");

if(isset($_POST['checkbox1']) && 
   $_POST['checkbox1'] == 'Yes')
{
   while($row = mysqli_fetch_array($sqldata, MYSQLI_ASSOC)) {
           echo '.';
           echo $row['cena'];
   }
}
?>

This all three connected files each others do that if the checkbox is checked this sql statement are executed : "SELECT cena FROM monitory;" but i want to execute this statement : "SELECT * FROM monitory WHERE cena=1000;" I tried to do this like around 2hours but i really don't now how to do this.

Thanks,




Aucun commentaire:

Enregistrer un commentaire