PDA

View Full Version : Dependent Dropdown Propblem


jay
07-30-2009, 12:11 PM
I have 3 dependent dropdown menues setup in dreamweaver that gets their data from a MySQL Table.


When I use dreamweaver ot control the dropdown they work fine, but the data being fed into my db is the numeric value used to control the dropdown not the label. If I change the value of the dropdown in dreamweaver to the lable the dropdown arent dependent anymore.



I heard that I have to set Foreign Keys to fix this.


I would apreciate any help I can get.



My first table is province:


CREATE TABLE `db`.`province` (
`id_prov` INTEGER UNSIGNED NOT NULL DEFAULT NULL AUTO_INCREMENT,
`name_prov` VARCHAR(45) NOT NULL,
PRIMARY KEY (`id_prov`)
)
ENGINE = InnoDB;


Second is City:


CREATE TABLE `db`.`city` (
`id_city` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`idprov_city` INTEGER UNSIGNED NOT NULL,
`name_city` VARCHAR(65) NOT NULL,
PRIMARY KEY (`id_city`)
)
ENGINE = InnoDB;


Third is Suburb:


CREATE TABLE `db`.`suburb` (
`id_suburb` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`idprov_suburb` INTEGER UNSIGNED NOT NULL,
`idcity_suburb` INTEGER UNSIGNED NOT NULL,
`name_suburb` VARCHAR(255) NOT NULL,
PRIMARY KEY (`id_suburb`)
)
ENGINE = InnoDB;

edbr
07-31-2009, 01:32 AM
post the code you are using for the select statement for the drop downs

jay
07-31-2009, 06:21 AM
Here is the select statement for the province dropdown:
<tr>
<td class="KT_th"><label for="province">Province:</label></td>
<td><select name="province" id="province">
<?php
do {
?>
<option value="<?php echo $row_province['id_prov']?>"><?php echo $row_province['name_prov']?></option>
<?php
} while ($row_province = mysql_fetch_assoc($province));
$rows = mysql_num_rows($province);
if($rows > 0) {
mysql_data_seek($province, 0);
$row_province = mysql_fetch_assoc($province);
}
?>
</select>
<?php echo $tNGs->displayFieldError("private_buyer", "province"); ?> </td>
</tr>

For City:

<tr>
<td class="KT_th"><label for="city">City:</label></td>
<td><select name="city" id="city" wdg:subtype="DependentDropdown" wdg:type="widget" wdg:recordset="city" wdg:displayfield="name_city" wdg:valuefield="id_city" wdg:fkey="idprov_city" wdg:triggerobject="province" >
</select>
<?php echo $tNGs->displayFieldError("private_buyer", "city"); ?> </td>
</tr>

For suburb:

<tr>
<td class="KT_th"><label for="suburb">Suburb:</label></td>
<td><select name="suburb" id="suburb" wdg:subtype="DependentDropdown" wdg:type="widget" wdg:recordset="suburb" wdg:displayfield="name_suburb" wdg:valuefield="name_suburb" wdg:fkey="idcity_suburb" wdg:triggerobject="city">
</select>
<?php echo $tNGs->displayFieldError("private_buyer", "suburb"); ?> </td>
</tr>