PDA

View Full Version : Update page and select options


phil.evans372967
05-18-2009, 07:05 AM
Hi all

I'm using a datassist update page to edit records in my database table.

I have a boolean field "contract_signed" which I want to be able to edit using a select drop down and options.

I have figured out how to dispay "yes" and "no" in the options based on the boolean field, and can set the second option (i.e. if field in database is set to 1/yes, that option is selected and the second option is set to 0/no and vice versa) and can change a yes to a no, but can't figure out what I'm doing wrong in the php to be able to change no to yes. Can anyone shed any light for me? My current code is

<select name="contract_signed" id="contract_signed">
<?php
do {
?>
<option value="<?php echo $row_WADAprop_address['contract_signed']?>">
<?php

if ($row_WADAprop_address['contract_signed']==1)
echo "Yes";
else echo "No";

?>
</option>
<?php
} while ($row_WADAprop_address = mysql_fetch_assoc($WADAprop_address));
$rows = mysql_num_rows($WADAprop_address);
if($rows > 0) {
mysql_data_seek($WADAprop_address, 0);
$row_WADAprop_address = mysql_fetch_assoc($WADAprop_address);
}
?>
<option value="<?php if($row_WADAprop_address['contract_signed']==1)
echo "No";
else echo "Yes";
?>">
<?php if($row_WADAprop_address['contract_signed']==1) echo "No"; else echo "Yes";?>
</option>
</select>

Thanks

Phil

Ray Borduin
05-18-2009, 08:00 AM
You should just create your list like:

<select name="contract_signed" id="contract_signed">
<option value="1">yes</option>
<option value="2">no</option>
</select>

Then highlight the list and click the dynamic button in the properties panel. Then chose the set selected value equal to: $row_WADAprop_address['contract_signed']

and DW will write the code for the list to select the correct value and you can still update it.

phil.evans372967
05-18-2009, 10:33 AM
Thanks Ray. I need to remember how easy the webassist tools make things, and have to stop over thinking things.

Cheers

Phil