javascript - jquery to existing php page -
im working on having search result list of bugs im trying use jquery m new jquery . im not able produce search result . can me or guide me how produce table based on name entered here code
<?php ini_set('display_errors','on'); include('connection.php'); $result=mysql_query("select * bug"); echo"bug list"; echo "\n"; echo "<table border=1>"; echo"<tr><td>bugid</td><td>name</td><td>description</td><td>priority</td><td>assigned to</td></tr>"; while($row=mysql_fetch_array($result)) { echo "</td><td>" .$row['bugid']. "</td><td>" . $row['name'] . "</td><td>" .$row['description']. "</td><td>" .$row['priority']. "</td><td>" .$row['assign']. "</td></tr>"; } echo "</table>"; ?> delete bug <form action="delbug.php" method="post"> enter bug id : <input type="text" name="bugid"> <input type="submit" value="submit"> </form> <a href="bugreport.php">report new bug<br/></a>
the page table lists reported bugs
now want have filter box alters table contents , display bugs reported specific user
i tried code doesnt work
<form method="get"> <label for="name">name</label> <input id="name" name="name" type="text"/> <button class="btnsearch">filter</button> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ function search(){ var title=$("#search").val(); if(title!=""){ $("#result").html("<img alt="ajax search" src='ajax-loader.gif'/>"); $.ajax({ type:"post", url:"search.php", data:"title="+title, success:function(data){ $("#result").html(data); $("#search").val(""); } }); } } $("#button").click(function(){ search(); }); $('#search').keyup(function(e) { if(e.keycode == 13) { search(); } }); }); </script> <?php ini_set('display_errors','on'); include('connection.php'); $name=$_post['name']; $result=mysql_query("select * bug name=$name "); eche "<table border=1>"; echo"<tr><td>bugid</td><td>name</td><td>description</td><td>priority</td><td>assigned to</td></tr>"; while($row=mysql_fetch_array($result)) { echo "<tr><td>" .$row['bugid']. "</td><td>" . $row['name'] . "</td><td>" .$row['description']. "</td><td>" .$row['priority']. "</td><td>" .$row['assign']. "</td></tr>"; } echo "</table>"; ?>
html code :
<html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> //$(document).ready(function(){ function search(){ var title = $("#name").val(); if(title!=""){ //$("#result").html('<img alt="ajax search" src="ajax-loader.gif"/>'); $.ajax({ type:"post", url:"search.php", data:"title="+title, success:function(data){ $("#result").html(data); $("#search").val(""); } }); } } $("#button").click(function(){ search(); }); $('#search').keyup(function(e) { if(e.keycode == 13) { search(); } }); // }); </script> </head> <body> <label for="name">name</label> <input id="name" name="name" type="text"/> <button class="btnsearch" onclick="search()">filter</button> <div id="result"></div> </body> </html>
php code :
search.php file:
<?php ini_set('display_errors','on'); include('connection.php') $title=$_get['title']; $result=mysql_query("select * bug name = '".$title."'"); echo "<table border=1>"; echo"<tr><td>bugid</td><td>name</td><td>description</td><td>priority</td><td>assigned to</td></tr>"; while($row=mysqli_fetch_array($result)) { echo "<tr><td>" .$row['bugid']. "</td><td>" . $row['name'] . "</td><td>" .$row['description']. "</td><td>" .$row['priority']. "</td><td>" .$row['assign']. "</td></tr>"; } echo "</table>"; ?>
Comments
Post a Comment