December 20, 201312 yr Sir I am using these codes <?php $myfilter="";?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title>My Contacts</title> <style type="text/css"> html {overflow:auto;} body{ background-color:#e7f4fe; padding:15px; } #box2{ float:left; width:500px; height:400px; border-color:#cceeff; padding:10px; background-color:#CCF; overflow:auto; } #box2 #resultTable{ border-bottom: 7px solid #9BAFF1; border-collapse: collapse; border-top: 7px solid #9BAFF1; font-family: "Lucida Sans Unicode","Lucida Grande",Sans-Serif; font-size: 12px; margin: 10px; text-align: center; width: 480px; } #box2 #resultTable th{ background: none repeat scroll 0 0 #B9C9FE; border-left: 1px solid #9BAFF1; border-right: 1px solid #9BAFF1; color: #003399; font-size: 13px; font-weight: normal; padding: 4px; } #box2 #resultTable td { background: none repeat scroll 0 0 #E8EDFF; border-left: 1px solid #AABCFE; border-top: 1px solid #9BAFF1; border-right: 1px solid #AABCFE; color: #666699; padding: 4px; } #amots{ padding:5px; border-radius:5px; width:250px; border:1px solid gray; background: url("images/sport_raquet.png") no-repeat scroll right 10px ;} </style> </head> <body onload="form1.filter.focus()"> <div id="box2"> <form name="form1" action="" method="post"> <label for="filter"><b>Filter</b></label> <input type="text" name="filter" id="amots" value="<?php echo $myfilter; ?>" /> <input type="submit" value="Filter Result" name="display"> <table cellpadding="2" cellspacing="0" width="80%" id="resultTable"> <thead> <tr> <th> <strong>ID</strong> </th> <th> <strong>Name</strong> </th> <th> <strong>Mobile</strong> </th> <th> <strong>City</strong> </th> <th> <strong>Country</strong> </th> </tr> </thead> <tbody><?php session_start(); require_once("connect.php"); function clean($str){ $cstr=trim($str); $cstr=addslashes($str); $cstr=htmlspecialchars($str); return $cstr; } if(isset($_POST['display'])) { $myfilter=clean($_POST['filter']); } else { $myfilter=""; } $sql = "SELECT * from contacts WHERE name LIKE ".$myfilter."% order by name"; echo $sql; $select = mysqli_query($con, $sql); $run_sel = mysqli_fetch_array($select); $row=mysqli_num_rows($select); $a = 1;while($a<=$row){ echo "<tr>"; echo "<td> <a href='contacts.php?id=".$run_sel['id']."'> <img border=\"noborder\" src=\"images/pencil.png\" title=\"Display\"></a></td>"; echo "<td align='left'> " . $run_sel["name"]. "</td>"; echo "<td> " . $run_sel["moba"]. "</td>"; echo "<td> " . $run_sel["city"]. "</td>"; echo "<td> " . $run_sel["country"] . "</td>"; echo "</tr>"; $run_sel = mysqli_fetch_array($select); $a++; }?> </tbody> </table> </form> </div> </body> </html> These codes display following data http://i43.tinypic.com/or45r8.jpg Now I want to apply incremental search with Filter box. For example: If I type "B" then all matching records (name field in table) which begins with "B" must appear in display list. Please help
Create an account or sign in to comment