<form method="post"> Search batchcode: <input type="text" name="code" id="query" /><input type="submit" value="Go" name="search" /><br /> <table> <tr> <td> ID: <br /> <input id="result" type="text" name="id1" value="<?php if(empty($id[0])){$id[0] = array(NULL);}else{echo $id[0];} ?>" readonly /> <br /> <input id="result" type="text" name="id2" value="<?php if(empty($id[1])){$id[1] = array(NULL);}else{echo $id[1];} ?>" readonly /> <br /> </td> <td> Name: <br /> <input id="result" type="text" name="name1" value="<?php if(empty($name[0])){$name[0] = array(NULL);}else{echo $name[0];} ?>" readonly /> <br /> <input id="result" type="text" name="name2" value="<?php if(empty($name[1])){$name[1] = array(NULL);}else{echo $name[1];} ?>" readonly /> <br /> </td> <td> Score 1: <br /> <input id="result" type="text" name="optA1" value="<?php if(empty($score1[0])){$score1[0] = array(NULL);}else{echo $score1[0];} ?>" onChange="optTotal1()" /> <br /> <input id="result" type="text" name="optA2" value="<?php if(empty($score1[1])){$score1[1] = array(NULL);}else{echo $score1[1];} ?>" onChange="optTotal2()" /> <br /> </td> <td> Score 2: <br /> <input id="result" type="text" name="optB1" value="<?php if(empty($score2[0])){$score2[0] = array(NULL);}else{echo $score2[0];} ?>" onChange="optTotal1()" /> <br /> <input id="result" type="text" name="optB2" value="<?php if(empty($score2[1])){$score2[1] = array(NULL);}else{echo $score2[1];} ?>" onChange="optTotal2()" /> <br /> </td> <td> Other Qualification: <br /> <input id="result" type="text" name="other_qual1" value="<?php if(empty($other_qual[0])){$other_qual[0] = array(NULL);}else{echo $other_qual[0];} ?>" readonly /> <br /> <input id="result" type="text" name="other_qual2" value="<?php if(empty($other_qual[1])){$other_qual[1] = array(NULL);}else{echo $other_qual[1];} ?>" readonly /> <br /> </td> <td> Interview: <br /> <input id="result" type="text" name="interview1" value="<?php if(empty($interview[0])){$interview[0] = array(NULL);}else{echo $interview[0];} ?>" readonly /> <br /> <input id="result" type="text" name="interview2" value="<?php if(empty($interview[1])){$interview[1] = array(NULL);}else{echo $interview[1];} ?>" readonly /> <br /> </td> <td> Total: <br /> <input id="result" type="text" name="total1" value="<?php if(empty($total[0])){$total[0] = array(NULL);}else{echo $total[0];} ?>" readonly onKeyUp="optTotal1()" /> <br /> <input id="result" type="text" name="total2" value="<?php if(empty($total[1])){$total[1] = array(NULL);}else{echo $total[1];} ?>" readonly onKeyUp="optTotal2()" /> <br /> </td> </tr> </table> <input type="submit" value="update" name="update" /> </form>
<script type="text/javascript"> $(document).ready(function(){ $("#query").autocomplete({ source : 'search.php', select : function(event,ui){ $("#result").html(ui.item.value); } }); }); </script>
<?php $q = $_GET['term']; mysql_connect("localhost","root",""); mysql_select_db("test"); $batchcode = $_POST['code']; $query = mysql_query("SELECT DISTINCT batchcode FROM score WHERE batchcode LIKE '$q%'"); $data = array(); while($row = mysql_fetch_array($query)){ $data[]=array('value'=>$row['batchcode']); $id[] = $rows['id']; $name[] = $rows['name']; $score1[] = $rows['score1']; $score2[] = $rows['score2']; $other_qual[] = $rows['score3']; $interview[] = $rows['score4']; $total[] = $rows['total']; } echo json_encode($data); ?>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)