Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>make this html structure on landing page</p> <pre><code>&lt;p&gt;&lt;b&gt;Category:&lt;/b&gt;&lt;br /&gt; &lt;?php $query="SELECT id,cat FROM cat"; $result = mysql_query ($query); echo"&lt;select name='cselect3' onChange='loadSubCats(this.value)' class='e1'&gt;&lt;option value='0'&gt;Please Select A Category&lt;/option&gt;"; // printing the list box select command while($catinfo=mysql_fetch_array($result)){//Array or records stored in $nt echo "&lt;option value=\"".htmlspecialchars($catinfo['cat'])."\"&gt;".$catinfo['cat']." &lt;/option&gt;"; } echo"&lt;/select&gt;"; ?&gt; &lt;div id='sub_categories'&gt;&lt;/div&gt; </code></pre> <p>make a js function assigned to the category dropdown</p> <pre><code>function loadSubCats(value) { $.post('load_sub_cats.php',{catid : value},function{data} { $('#sub_categories').html(data); }); } </code></pre> <p>now in your load_sub_cats.php</p> <pre><code>&lt;p&gt;&lt;b&gt;Subcat1:&lt;/b&gt;&lt;br /&gt; &lt;?php $catid = $_POST['cat_id'] $query="SELECT id,subcat FROM subcat where catid = $catid"; $result = mysql_query ($query); echo"&lt;select name='sselect1' class='e1'&gt;&lt;option value='0'&gt;Please Select A Category&lt;/option&gt;"; // printing the list box select command while($catinfo=mysql_fetch_array($result)){//Array or records stored in $nt echo "&lt;option value=\"".htmlspecialchars($catinfo['subcat'])."\"&gt;".$catinfo['subcat']."&lt;/option&gt;"; } echo"&lt;/select&gt;"; ?&gt; </code></pre> <p>You will need to include jquery to this code work.</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.
    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