jeudi 24 mars 2016

Using Check Box to Detemine MySql query

I have written a php file that has six independent queries--they all do the same thing but call from a different table example. query 1 selects * from table one and inserts A,B into table 9, query 2 selects * from table two and inserts A,b into table nine, and so on and so on. then at the end it joins everything in table 9 together by A and produces an output. What i would like to be able to do is use check boxes on a webpage (i know how to HTML to get them checked and unchecked) to have the php file run 5 of the queries or 2 or all of them depending on which checkbox is check--so if all the check boxes are checked (default) it would run all the queries but if the checkbox for table two was unchecked then it would not run that query but still do everything else. Have no idea how to get started..I can use php, ajax, js whatever is best (it is a huge file so calling duplicate files is not possible, must only run one per click)

$first = $conn->query("select * from one  ");
while ($row = $first->fetch_assoc()) {
$firstA = $row['A'];
$FirstB = $row['B'];

$conn->query("insert into nine (A, B) values ($firstA,$firstb)");

$second = $conn->query("select * from two  ");
while ($row = $second->fetch_assoc()) {
$secondA = $row['A'];
$secondB = $row['B'];

$conn->query("insert into nine (A, B) values ($secondA,$secondb)");




Aucun commentaire:

Enregistrer un commentaire