Note that there are some explanatory texts on larger screens.

plurals
  1. POVariable was undefined when I get $q?
    primarykey
    data
    text
    <p>I working now with this code below, I want to display rfq list depends on rfq #. But when I choose, the $q was undefined.</p> <p>Dropdown.php</p> <pre><code> &lt;?php $con = mysql_connect("localhost","root",""); $db = mysql_select_db("app",$con); $get=mysql_query("SELECT rfq FROM procurement GROUP BY rfq ORDER BY rfq"); $option = ''; while($rows = mysql_fetch_assoc($get)) { $option .= '&lt;option value = "'.$rows['rfq'].'"&gt;'.$rows['rfq'].'&lt;/option&gt;'; } ?&gt; &lt;form&gt; &lt;select name="users" onchange="showUser()"&gt; &lt;option value="ALL"&gt;ALL&lt;/option&gt; &lt;?php echo $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; getuser.php &lt;?php include('connect.php'); $q=$_GET["q"]; $sql="SELECT rfq FROM procurement WHERE rfq='".$q."'"; $result = mysql_query($sql); echo "&lt;table border='1'&gt; &lt;tr&gt; &lt;th&gt;MOD&lt;/th&gt; &lt;th&gt;RFQ #&lt;/th&gt; &lt;/tr&gt;"; while($row = mysql_fetch_array($result)) { echo "&lt;tr&gt;"; echo "&lt;td&gt;".$row['mode_of_procurement']."&lt;/td&gt;"; echo "&lt;td&gt;".$row['rfq']."&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; echo $q; mysql_close(); ?&gt; </code></pre> <p>But the value of $q didn't display, when I echo the $q the value is UNDEFINED. Why is that?</p> <p>And here's the script</p> <pre><code>&lt;script&gt; function showUser(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; </code></pre> <p><img src="https://i.stack.imgur.com/eNMUk.jpg" alt="enter image description here"></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.
 

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