php - JavaScript - How do I execute certain query from dropdown select? -
i'd simplify code execute query based on user choose
the idea user show query based on base + group query when visit page first time. next, can decide data they'd see dropdown below
//base $material = "select material, count(material) 'total' `khitable` "; $storagelocation = "select sloc ,count(sloc) 'total' `khitable`"; $verifstock = "select verif_stock ,count(verif_stock) 'total' `khitable`"; //tipe pipa $erw = "where material '%er%'"; $sp = "where material '%sp%'"; $acc = "where material '%acc%'"; //status pengerjaan $fg = "and material not '%sf-%'"; $wip = "and material '%sf-%'"; //ketersediaan $so = "and so_number not '%605%'"; $buffer = "and so_number '%605%'"; $fs = "and material '%-fs%"; //group $groupmaterial = "group material"; $groupsloc = "group sloc"; $groupverifstock = "group verif_stock";
and next user able choose data show dropdown list below
<div class="row"> <div class="input-field col s4"> <select class="validate"> <option value="" disabled selected>pilih pilihan anda</option> <option value="1">finish good</option> <option value="2">semi finish (wip)</option> </select> <label >pilih berdasarkan status pengerjaan</label> </div> <div class="input-field col s4"> <select class="validate"> <option value="" disabled selected>pilih pilihan anda</option> <option value="1">sales order</option> <option value="2">buffer</option> <option value="3">free stock</option> </select> <label >pilih berdasarkan status ketersediaan</label> </div> </div>
so there 2 dropdown, , user see based on been choose on dropdown list. don't understand yet on code. here.
p.s. : data suppose viewed database, based on query shown
php:
//base $select["material"] = "select material, count(material) 'total' `khitable` "; $select["storagelocation"] = "select sloc ,count(sloc) 'total' `khitable`"; $select["verifstock"] = "select verif_stock ,count(verif_stock) 'total' `khitable`"; //tipe pipa $where["erw"] = "where material '%er%'"; $where["sp"] = "where material '%sp%'"; $where["acc"] = "where material '%acc%'"; //status pengerjaan $and1["fg"] = "and material not '%sf-%'"; $and1["wip"] = "and material '%sf-%'"; //ketersediaan $and2["so"] = "and so_number not '%605%'"; $and2["buffer"] = "and so_number '%605%'"; $and2["fs"] = "and material '%-fs%"; //group $group["groupmaterial"] = "group material"; $group["groupsloc"] = "group sloc"; $group["groupverifstock"] = "group verif_stock"; $query = $select[$_get["query_select"]]." ". $where[$_get["query_where"]]." ".$and1[$_get["query_and1"]]. " ".$and1[$_get["query_and2"]]." ".$group[$_get["query_group"]];
html:
<form action="yourscript.php" method="get"> <!-- here form elements material,storagelocation etc --> ................. <div class="row"> <div class="input-field col s4"> <select class="validate" name="query_and1"> <option value="" disabled selected>pilih pilihan anda</option> <option value="fg">finish good</option> <option value="wip">semi finish (wip)</option> </select> <label >pilih berdasarkan status pengerjaan</label> </div> <div class="input-field col s4"> <select class="validate" name="query_and2"> <option value="" disabled selected>pilih pilihan anda</option> <option value="so">sales order</option> <option value="buffer">buffer</option> <option value="fs">free stock</option> </select> <label >pilih berdasarkan status ketersediaan</label> </div> </div> ............ </form>
i hope understand idea
wiki
Comments
Post a Comment