Note that there are some explanatory texts on larger screens.

plurals
  1. POFetching Images and other Details in Index page based on two dropdown selected value?
    primarykey
    data
    text
    <p>I am new to php.I have a problem with a dropdown list. Let me explain it in little detail.I have a database that contains Two Tables: firstCata and subCata. The table subCata references firstCata ID. Now in my index.php page I have a form with 2 drop downs. First is for firstCata and second shows values based on first from my database. All this I had done using Ajax.Code is Below. Problem is that using ajax I had displayed a second drop down on tag in index.php. How can I show other details of subCata in index.php Page?</p> <pre><code>&lt;head&gt; &lt;script type="text/javascript"&gt; function getSubCata(str) { 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("result").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getSunCata.php?q="+str.value,true); xmlhttp.send(); } &lt;/script&gt; &lt;/head&gt; &lt;select onchange='getSubCata(this)'&gt; &lt;?php $query=mysql_query("SELECT * FROM firstCata") or die(mysql_error()); while($rec=mysql_fetch_array($query)) { ?&gt; &lt;option value="&lt;?php echo $rec['firstCata_id'];?&gt;"&gt;&lt;?php echo $rec['firstCata_name'];?&gt;&lt;/option&gt; &lt;?php } ?&gt; &lt;/select&gt; </code></pre> <p>and my getSunCata.php code is like</p> <pre><code>&lt;?php mysql_connect('localhost','root',''); mysql_select_db('mainCata') or die(mysql_error()); ?&gt; &lt;select&gt; &lt;?php $id=$_GET['q']; echo $id; $query=mysql_query("SELECT * FROM subcata where firstCata_id=$id") or die(mysql_error()); while($rec=mysql_fetch_array($query)) { echo $rec['subCata_name']; ?&gt; &lt;option id="a"value="echo $rec['subCata_id'];"&gt; &lt;?php echo $rec['subCata_name']; ?&gt; &lt;/option&gt; &lt;?php } ?&gt; &lt;/select&gt; </code></pre>
    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