Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2006
    Location
    Decatur Illinois
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    dependent dropdowns in dreamweaver?

    Anyone know where i can find instructions on how to make database (phpMySql) dependnt dropdowns in dreamweaver?

  • #2
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts
    you need to...

    1. Create a recordset for the table that you want to use to populate the dropdown box

    2. Create a form and add a dropdown menu

    3. Locate the properties menu and click on the dynamic button

    4. Now select the recordset created above from the 'Options from recordset' menu and select the labels and values

    Now when you load this page the dropdown menu will populate with the values from the recordset.

    PHP Code:
    <?
    require_once('../Connections/Con_SJMDatabase.php');

    mysql_select_db($database_Con_SJMDatabase$Con_SJMDatabase);
    $query_rs_Source "SELECT * FROM tblsource";
    $rs_Source mysql_query($query_rs_Source$Con_SJMDatabase) or die(mysql_error());
    $row_rs_Source mysql_fetch_assoc($rs_Source);
    $totalRows_rs_Source mysql_num_rows($rs_Source);

    ?>

    <select class="textboxText" name="SourceFK" id="source">
                <?php
    do {  
    ?>
                <option value="<?php echo $row_rs_Source['fldSourceID']?>"<?php if (!(strcmp($row_rs_Source['fldSourceID'], $_GET['source']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rs_Source['fldSourceFN']?></option>
                <?php
    } while ($row_rs_Source mysql_fetch_assoc($rs_Source));
      
    $rows mysql_num_rows($rs_Source);
      if(
    $rows 0) {
          
    mysql_data_seek($rs_Source0);
          
    $row_rs_Source mysql_fetch_assoc($rs_Source);
      }
    ?>
    </select>
    This is what the code looks like that it generates or should look like

  • #3
    New Coder
    Join Date
    Aug 2006
    Location
    Decatur Illinois
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok i did all of that and i think i generated it wrong can you look at this and let me know?

    Code:
    	    <tr><td>Industry:</td><td>
    			    <select name="industry" id="center">
    			      <option value="">Select an Industry...</option>
    			      <?php do { ?>
    			      <option value="<?php echo $row_rs_industry['industry_name']; ?>"><?php echo $row_rs_industry['industry_name']; ?></option>
    			      
    			      <?php } while ($row_rs_industry = mysql_fetch_assoc($rs_industry)); ?>
    		        </select></td></tr>
    			    <tr><td width="125">Product Category: </td>  <td>
    			    <select name="prodcat" id="center">
    			      <option value="">Select a product category...</option>
    			      <?php do { ?>
    			      <option value="<?php echo $row_rs_productcategory['productCat_name']; ?>"><?php echo $row_rs_productcategory['productCat_name']; ?></option>
    			      
    			      <?php } while ($row_rs_productcategory = mysql_fetch_assoc($rs_productcategory)); ?>
    		        </select><select name"test">
    		          <?php
    do {  
    ?>
    		          <option value="<?php echo $row_rs_industry['industry_name']?>"<?php if (!(strcmp($row_rs_industry['industry_name'], $row_rs_productcategory['productCat_name']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rs_industry['industry_name']?></option><?php
    } while ($row_rs_industry = mysql_fetch_assoc($rs_industry));
      $rows = mysql_num_rows($rs_industry);
      if($rows > 0) {
          mysql_data_seek($rs_industry, 0);
    	  $row_rs_industry = mysql_fetch_assoc($rs_industry);
      }
    ?>
                                    </select></td></tr>
    This should come out with values based on what was selected in the industry and i think its on the industry id? not sure both tables have that and the industry id is the fk in that table. Right now it just displays the blank field..


  •  

    Posting Permissions

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