Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For retrieving data using Ajax+jQuery, you must write the following code: </p> <pre><code> &lt;html&gt; &lt;script type="text/javascript" src="jquery-1.3.2.js"&gt; &lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $("#display").click(function() { $.ajax({ //create an ajax request to display.php type: "GET", url: "display.php", dataType: "html", //expect html to be returned success: function(response){ $("#responsecontainer").html(response); //alert(response); } }); }); }); &lt;/script&gt; &lt;body&gt; &lt;h3 align="center"&gt;Manage Student Details&lt;/h3&gt; &lt;table border="1" align="center"&gt; &lt;tr&gt; &lt;td&gt; &lt;input type="button" id="display" value="Display All Data" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;div id="responsecontainer" align="center"&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>For mysqli connection, write this:</p> <pre><code>&lt;?php $con=mysqli_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysqli_error()); } ?&gt; </code></pre> <p>For displaying the data from database, you must write this :</p> <pre><code>&lt;?php include("connection.php"); mysqli_select_db("samples",$con); $result=mysqli_query("select * from student",$con); echo "&lt;table border='1' &gt; &lt;tr&gt; &lt;td align=center&gt; &lt;b&gt;Roll No&lt;/b&gt;&lt;/td&gt; &lt;td align=center&gt;&lt;b&gt;Name&lt;/b&gt;&lt;/td&gt; &lt;td align=center&gt;&lt;b&gt;Address&lt;/b&gt;&lt;/td&gt; &lt;td align=center&gt;&lt;b&gt;Stream&lt;/b&gt;&lt;/td&gt;&lt;/td&gt; &lt;td align=center&gt;&lt;b&gt;Status&lt;/b&gt;&lt;/td&gt;"; while($data = mysqli_fetch_row($result)) { echo "&lt;tr&gt;"; echo "&lt;td align=center&gt;$data[0]&lt;/td&gt;"; echo "&lt;td align=center&gt;$data[1]&lt;/td&gt;"; echo "&lt;td align=center&gt;$data[2]&lt;/td&gt;"; echo "&lt;td align=center&gt;$data[3]&lt;/td&gt;"; echo "&lt;td align=center&gt;$data[4]&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload