SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Mar 2011
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help in two dropdown list.

    Can anyone tell me what i'am doing wrong..

    Code PHP:
    <?php
    session_start();
    include_once("conn.php");
    $cat=mssql_query("Select * from tblCat");
     
     
    ?>
    <html>
    <head>
    </head>
    <body>
    <table>
     
    		<?php
    		echo '<tr>';
    			echo '<td>Category</td>';
    			echo '<td>';
     
     
    					echo "<select name='catname' >";
    					echo "<option></option>";
    					while($catname=mssql_fetch_assoc($cat)){
    						echo "<option value='".$catname[CatName]."'>".$catname['CatName']."</option>";
    					}
     
    			echo '</td>';
    		echo '</tr>';
    		echo '<tr>';
    			echo '<td>Sub-Category</td>';
    			echo '<td>';
    				if($subcat=mssql_query("Select * from tblSubCat where CatName='$_POST[catname]'"))
    				echo "<Select name='catname'>";
    				echo "<option></option>";
    				while($subcatname=mssql_fetch_assoc($subcat)){
    					echo "<option value='".$subcatname[CatName]."'>".$subcatname['CatName']."</option>";
    				}
    		echo '</tr>';	
    		?>
     
     
    </table>
    </body>
    </html>

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    71 Post(s)
    Tagged
    0 Thread(s)
    echo "<option value='".$catname[CatName]."'>".$catname['CatName']."</option>";

    ~One of these things is not like the others~
    (Yes, it's a Sesame Street kind of morning.)

    Second thing is that you've got two select boxes with the same name.
    Third thing is that your SELECT query isnt getting it's variable. Wrap it in {}'s, or escape the string.

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2011
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply..

    How can i populate my subcatname with the coresponding Catname.

    Thanks..

  4. #4
    SitePoint Zealot
    Join Date
    Mar 2011
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,

    I change the things that you said but the question still remain how can i populate the subcatname with the catname.

    iam reallt desperate with this.Thanks.

  5. #5
    SitePoint Zealot
    Join Date
    Mar 2011
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yup..is there a way that in can be done with out ajax or java script.

  6. #6
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    71 Post(s)
    Tagged
    0 Thread(s)
    Without submitting the form inbetween? AJAX javascript.

  7. #7
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    71 Post(s)
    Tagged
    0 Thread(s)
    Not without submitting the form.

  8. #8
    SitePoint Zealot
    Join Date
    Mar 2011
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    on different page?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •