Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-13-2007, 04:03 PM   PM User | #1
mrjameer
Regular Coder

 
Join Date: Aug 2006
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
mrjameer is an unknown quantity at this point
interdependent select boxes

hi,

i have 2 select boxes on a page.what i want to do is when i select one option from 1st select box then related options will be displayed in 2nd select box.
i have the following code to display both select box options from 2 mysql tables.

or i have to go with javascript.any of your idea will be surely appreciated
regards
mrjameer


PHP Code:
if($_GET['action']=="create_subsubcategory")
{

    if(isset($_POST['Submit']))
    {
    
    $category_name=$_POST['category_name'];
    $subcategory=$_POST['subcategory'];
    $subsubcat=$_POST['subsubcat'];

    
    $sql="INSERT INTO subsubcategories Values('','$category_name','$subcategory','$subsubcat')";
    $result=mysql_query($sql,$db_connect) or die (mysql_error());
if($result)
        {
    echo "<center>NEW SUB SUB CATEGORY CREATED</center>";
        }
        else
        {
            echo "Sorry sub sub Category not created";
        }
    }
    else
    {

    
?>
<br><br><br>
<form name="fname" method="post" action="index.php?action=create_subsubcategory">
<table width="350" border="1" cellspacing="0" cellpadding="0" align="center" class="border">
                <tr>
                  <td>
                    <table width="350" border="1" cellspacing="1">
                      <tr align="center">
                        <td colspan="5" class="analyzer">Create Sub Sub Category</td>
                      </tr>
                      <tr align="center">
                       
                        
                       
                        <td class="analyzer"><select name="maincat"><option value=''>Select a Category....</option><?php

$sql
="SELECT * FROM categories";
$result=mysql_query($sql) or die (mysql_error());
while(
$newarray=mysql_fetch_array($result))
{

   
$category_name=$newarray['category_name'];

   
   echo
"<option value='$category_name'>$category_name</option>";

}

echo
"</select>";


    
?></td><td class="analyzer">MainCategory</td></tr>
                        <tr  align="center"><td class="analyzer"><select name="maincat"><option value=''>Select a Sub Category....</option><?php

$sql
="SELECT * FROM subcategories";
$result=mysql_query($sql) or die (mysql_error());
while(
$newarray=mysql_fetch_array($result))
{

   
$subcategory=$newarray['subcategory'];

   
   echo
"<option value='$subcategory'>$subcategory</option>";

}

echo
"</select>";


    
?></td><td class="analyzer">Sub Category</td></tr>
                        <tr  align="center"><td class="analyzer"><input type="text" name="subsubcat" value=""></td><td class="analyzer">Sub Sub Category</td></tr>
                        <tr>
                                                <td class="analyzer" colspan="2" align="center"><input type="submit" name="Submit" value="Submit"></td>
                        

                      </table>
                      </table>

                    <?php

    
}
    
}
mrjameer is offline   Reply With Quote
Old 11-13-2007, 04:12 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Same question just asked:

http://codingforums.com/showthread.php?t=127707
__________________
Fumigator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:13 AM.


Advertisement
Log in to turn off these ads.