I need some help with MySQL, jquery and PHP. Here is my code :
HTML
<label class="checkbox"><input type="checkbox" name="code_site1" class="code_site1" checked="checked">Code 1</label>
<label class="checkbox"><input type="checkbox" name="code_site2" class="code_site2" checked="checked">Code 2</label>
<label class="checkbox"><input type="checkbox" name="code_site3" class="code_site3" checked="checked">Code 3</label>
<label class="checkbox"><input type="checkbox" name="code_site4" class="code_site4" checked="checked">Code 4</label>
Jquery
<script>
$(document).ready(function(){
$("#flip").click(function(){
$("#panel").slideToggle("slow");
});
});
</script>
Everything here is working. But, I have an SQL query:
SELECT * from site;
I'd like to change it to :
SELECT * from site WHERE codeSite=$theOneThatIsChecked;
Actually, all I want is to establish a sql query depending on what is checked or note. For example, if code_site1 is checked, I'd like to have my SQL query like :
SELECT * from site WHERE codeSite=1;
That's pretty much I'm trying to do but I really don't know how to do it in PHP without submitting...
Can you help me ?
Thanks a lot !
EDIT:
First, thank you for your answsers. I tried the different solutions, but I still have an issue.
Actually, what I do : - On my main page index.php I have an ajax script that points to "do.php" when I click on a submit button, - On the "do.php" page I store a query depending on which checkboxes I have checked, - Finally, thanks to :
success:function(data){
alert(data);
}
I can print the query that I made on "do.php". I'd like to know if I can store it in a php variable on my main page, in order to execute the query on my main page.
Thank you !