...

View Full Version : dependent dropdowns in dreamweaver?



Codeman0013
09-11-2006, 10:30 PM
Anyone know where i can find instructions on how to make database (phpMySql) dependnt dropdowns in dreamweaver?

mic2100
09-12-2006, 10:00 PM
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.



<?
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_Source, 0);
$row_rs_Source = mysql_fetch_assoc($rs_Source);
}
?>
</select>


This is what the code looks like that it generates or should look like

Codeman0013
09-13-2006, 10:03 PM
Ok i did all of that and i think i generated it wrong can you look at this and let me know?


<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..



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum