malatamil 9 Junior Poster

I have one dropdownlist in that i want to display some categories. and second is subcategory in checkboxes ,while selecting any category from dropdownlist that related subcategory should display in checkbox, after that whatever i need to select in checkbox values to store in database.
here is my code:

Main Category:

           <select name="catagory" id="catagory">
            <option value='' selected="selected">...Select a Category...</option>
            <?php  
                include("db.php");
                $query = "SELECT `id`,`MainCatagory` FROM `catagorykeywords` ";
                $result = mysql_query($query);

    //echo mysql_error();
    while($rows = mysql_fetch_array($result))
    {
    $selected = "";
    $categoryId = $rows['id'];
    $categoryName = $rows['MainCatagory'];
    if($catid == $categoryId)
    {
    $selected = "selected";
    }
    ?>
            <option value="<?php echo $categoryId; ?>" <?php echo $selected; ?> id="dosecondfilter" onchange="dosecond()"><?php echo $categoryName; ?></option>
            <?php }  ?>

         </select>


<div class="subcat_tick" id="subcat_tick"><ul>                
            <?php  

                include("db.php");
                $getval = 
                $query = "SELECT DISTINCT `Subcatagory`,`id`, `MainCatid` FROM `subcatagorykeywords` ";
                $result = mysql_query($query);

    //echo mysql_error();
    while($rows = mysql_fetch_array($result))
    {
    $selected = "";
    $categoryId = $rows['id'];
    $categoryName = $rows['Subcatagory'];
    if($catid == $categoryId)
    {
    $selected = "selected";
    }
    ?>
    <li><input name="relatedcatagories" class="tick" type="checkbox" value="<?php echo $categoryId; ?>" /><span><?php echo $categoryName; ?></span></li>
    <?php } ?></ul>
         </div>

Thanks in advance..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.