php - how to prompt search query into a dynamic iframe -
hi there creating data grid loads data database , had created search box prompts search queries when user inputs value want show search query same iframe loading file of data table , when search box empty should show data table , if user enters query should load query here script
<div style="float: right; border: 1px; padding-right: 20px;"> <div class="search"> <input type="text" name="s" maxlength="64" placeholder="search" id="inputstring" onkeyup="lookup(this.value);" /> <img src="images/srch.png" id="srch_btn"/> </div> </div> </div> </div> </div> <table border="0" width="100%" class="myclass" height="30px"> <tr> <td width="80px" align="center"><font color="black" size="3px">sr no.</font></td> <td width="80px" align="center"><font color="black" size="3px">br no.</font></td> <td width="180px" align="center"><font color="black" size="3px">name</font></td> <td width="200px" align="center"><font color="black" size="3px">address</font></td> <td width="120px" align="center"><font color="black" size="3px">city</font></td> <td width="80px" align="center"><font color="black" size="3px">pin</font></td> <td width="80px" align="center"><font color="black" size="3px">mobile</font></td> <td width="120px" align="center"><font color="black" size="3px">email</font></td> <td width="80px" class="myclass" align="center"><font color="black" size="3px">actions</font></td> </tr> </table> <div id="suggestions">/****file shows search queries**/ <iframe src="record.php" width="1150" height="900" frameborder="0"></iframe> /** file loads data table**/ </div>
here search script
$db = new mysqli('localhost', 'root', '', 'mdb'); if(!$db) { // show error if cannot connect. echo 'error: not connect database.'; } else { // there posted query string? if(isset($_post['querystring'])) { $querystring = $db->real_escape_string($_post['querystring']); if(strlen($querystring) >0) { $query = $db->query("select * mdb (`name` '%" . $querystring . "%') or (grno '%". $querystring ."%') or (`address` '%". $querystring ."%') or (`city` '%". $querystring ."%') or (pin '%". $querystring ."%') or (mobile '%". $querystring ."%') or (`email` like'%". $querystring ."%') order vouchno limit 8"); if($query) { echo "<table width='100%'>"; echo "<tr>"; echo "<th align=left>name</th>"; echo "<th align=left>address</th>"; echo "<th align=left>city</th>"; echo "<th align=left>pin</th>"; echo "<th align=right>mobile</th>"; echo "<th align=left>email</th>"; echo "</tr>"; while ($result = $query ->fetch_object()) { echo "<tr>"; echo "<td><span class=\"category\">$result->name</span></td>"; echo "<td>$result->address</td>"; echo "<td>$result->city</td>"; echo "<td>$result->pin</td>"; echo "<td align=right>$result->mobile</td>"; echo "<td>$result->email</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan=9>"; echo "<hr/>"; echo "</td>"; echo "<tr>"; $name = $result->name; if(strlen($name) > 35) { $name = substr($name, 0, 35) . "..."; } $description = $result->address; if(strlen($description) > 80) { $description = substr($description, 0, 80) . "..."; } } echo "</table>"; echo '<span class="seperator"><strong>no further records found</strong> </span><br class="break" />'; } else { echo 'error: there problem query.'; } } else { echo "record.php"; } } else { echo 'there should no direct access script!'; } }
i think ajax can mean. why don't somthing instead of iframe?
check this
$('#div').load('somefile.php','params');
and scrolling div use in css
css
#div{ width:500px; height:300px; overflow:scroll; }
here jsfiddle.
Comments
Post a Comment