File 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
<style>.frmSearch {border: 1px solid #F0F0F0;background-color:#C8EEFD;margin: 2px 0px;padding:40px;} #bar-list{float:left;list-style:none;margin:0;padding:0;width:190px;} #bar-list li{padding: 10px; background:#FAFAFA;border-bottom:#F0F0F0 1px solid;} #bar-list li:hover{background:#F0F0F0;} #search-box{padding: 10px;border: #F0F0F0 1px solid;} </style> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <div class="form-group"> <label for="searchby" class="all_label">Search By</label> <input type="hidden" id="barID" name="barID" value="<?php if(isset($_POST['barID'])) echo $_POST['barID']; ?>"/> <input type="text" id="search-box" class="form-control" name="search-box" placeholder="Bar name" value="<?php if(isset($_POST['search-box'])) echo $_POST['search-box']; ?>"/> <div id="suggesstion-box"></div> <div class="clearfix"></div> </div> <div class="form-group"> <select class="form-control" name="search"> <option value="">Select</option> <option value="0" <?php if(isset($_POST['search']) && $_POST['search']=='0') echo 'selected="selected"'; ?>>Live Photos</option> <option value="1" <?php if(isset($_POST['search']) && $_POST['search']=='1') echo 'selected="selected"'; ?>>Spammer Photos</option> </select> </div> <input type="submit" name="submit" value="Search" class="btn btn-default"> </p> </form> <script> $(document).ready(function(){ $("#search-box").keyup(function(){ $.ajax({ type: "POST", url: "readbar.php", data:'keyword='+$(this).val(), beforeSend: function(){ $("#search-box").css("background","#FFF url(image/LoaderIcon.gif) no-repeat 165px"); }, success: function(data){ $("#suggesstion-box").show(); $("#suggesstion-box").html(data); $("#search-box").css("background","#FFF"); } }); var textBox = $.trim( $("#search-box").val() ) if (textBox == "") { $("#barID").val(""); } }); }); function selectCountry(val,id) { $("#search-box").val(val); $("#barID").val(id); $("#suggesstion-box").hide(); } </script> |
File 2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<?php set_time_limit(0); include_once("include/applicationtop.php"); if(!isset($_SESSION['logged'])){ redirectToLocation("location:index.php"); } if(!empty($_POST["keyword"])) { $query ="SELECT * FROM ".TABLE_BAR." WHERE barname like '" . $_POST["keyword"] . "%' ORDER BY barname LIMIT 0,6"; $result = mysqli_query($con,$query); if(mysqli_num_rows($result) > 0){ ?> <ul id="bar-list"> <?php while($record=mysqli_fetch_array($result)){ ?> <li onClick="selectCountry('<?php echo $record["barname"]; ?>','<?php echo $record["bar_id"]; ?>');"><?php echo $record["barname"]; ?></li> <?php } ?> </ul> <?php } } ?> |
Leave a reply