Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to display the data from mysql
    primarykey
    data
    text
    <p>I am trying to display the data onselect method but the data is not getting displayed. This is the code.</p> <p>index.html</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script&gt; function showUser(str) { alert(str); if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getuser.php?q="+str,true); xmlhttp.send(); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form&gt; &lt;select name="users" onchange="showUser(this.value)"&gt; &lt;option value=""&gt;Select a person:&lt;/option&gt; &lt;option value="1"&gt;MEGHALI&lt;/option&gt; &lt;option value="2"&gt;SONY&lt;/option&gt; &lt;option value="3"&gt;DHANU&lt;/option&gt; &lt;option value="4"&gt;ADITYA&lt;/option&gt; &lt;option value="5"&gt;MAHESH&lt;/option&gt; &lt;option value="6"&gt;NEERAJ&lt;/option&gt; &lt;option value="7"&gt;VINEET&lt;/option&gt; &lt;option value="8"&gt;ASHWINI&lt;/option&gt; &lt;option value="9"&gt;SANTOSH&lt;/option&gt; &lt;/select&gt; &lt;/form&gt; &lt;br&gt; &lt;div id="txtHint"&gt;&lt;b&gt;Person info will be listed here.&lt;/b&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and the getuser.php</p> <pre><code>&lt;?php $q = intval($_GET['q']); $con = mysqli_connect("localhost", "root", " ", "flowers"); if (!$con) { die('Could not connect: ' . mysqli_error($con)); } mysqli_select_db($con,"FLOWERS"); $sql="SELECT * FROM STUDENTS WHERE id = '".$q."'"; $result = mysqli_query($con,$sql); echo "&lt;table border='1'&gt; &lt;tr&gt; &lt;th&gt;ID&lt;/th&gt; &lt;th&gt;NAME&lt;/th&gt; &lt;th&gt;CITY&lt;/th&gt; &lt;th&gt;PHONE&lt;/th&gt; &lt;/tr&gt;"; while($row = mysqli_fetch_array($result)) { echo "&lt;tr&gt;"; echo "&lt;td&gt;" . $row['ID'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['NAME'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['CITY'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['PHONE'] . "&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; mysqli_close($con); ?&gt; </code></pre> <p>I guess the <code>getuser.php?q="+str</code> is not getting passed.<br> Please help as I am newbie to ajax.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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