Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Updated answer following comment feedback...</p> <p>Snippet 2: <pre><code> while ($row = mysql_fetch_array($contactresult)) { echo '&lt;option value="' . $row['ContactID'] . '"&gt;' . $row['ContactLastName'] . ', ' . $row['ContactFirstName'] . '&lt;/option&gt;'; } ?&gt; &lt;/select&gt; &lt;/form&gt; &lt;div id="txtHint"&gt;&lt;b&gt;Person info will be listed here.&lt;/b&gt;&lt;/div&gt; </code></pre> <p>Snippet 3:</p> <pre><code>&lt;?php $q=$_GET["q"]; // connection esablished $sql="SELECT * FROM contacts WHERE ContactID = '".$q."'"; $result = mysql_query($sql); echo "&lt;table border='1'&gt; &lt;tr&gt; &lt;th&gt;Firstname&lt;/th&gt; &lt;th&gt;Lastname&lt;/th&gt; &lt;/tr&gt;"; while($row = mysql_fetch_array($result)) { echo "&lt;tr&gt;"; echo "&lt;td&gt;" . $row['ContactFirstName'] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row['ContactLastName'] . "&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; ?&gt; </code></pre> <p>Your final page needs to look like this: </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Hello&lt;/title&gt; &lt;/head&gt; &lt;script type="text/javascript"&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() { //alert(xmlhttp.readyState + " " + xmlhttp.status); if (xmlhttp.readyState==4 &amp;&amp; (xmlhttp.status==200 || window.location.href.indexOf("http")==-1)) { //alert("receieved") document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","http://oldkitbag.com/kerrybog/modify-profile/tester-engine.php?q="+str,true); xmlhttp.send(null); //alert("sent") } &lt;/script&gt; &lt;body&gt; &lt;form&gt; &lt;select name="profile-owner" onchange="showUser(this.value)"&gt; &lt;option value="1"&gt;Griffin, Peter&lt;/option&gt;&lt;option value="2"&gt;Griffin, Lois&lt;/option&gt;&lt;option value="3"&gt;Quagmire, Glen&lt;/option&gt;&lt;option value="4"&gt;Swanson, Joseph&lt;/option&gt; &lt;/select&gt; &lt;/form&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>Copy and paste this code to test and then when you are happy the script works replace all the static HTML text within the form with PHP code and all will work fine... hopefully!!</p>
    singulars
    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