takeiteasy Posted May 8, 2006 Share Posted May 8, 2006 In my Add form, i have radio buttons for payment mode consisting of Cash, Credit Card and Cheque. If i select the radio button for Cash, MySQL will add the record as 'Cash' right....but wad if i wan to display the stored record in my Edit form in radio button Cash, Credit Card. Cheque, checked Cash? how do i go about the code?TIA!This is my code in Add form[code]<input type='radio' name='paymentMode' value='Cash'>Cash <input type='radio' name ='paymentMode' value='CreditCard'>Credit Card <input type='radio' name ='paymentMode' value='Cheque'>[/code] Link to comment https://forums.phpfreaks.com/topic/9288-displaying-update/ Share on other sites More sharing options...
trq Posted May 8, 2006 Share Posted May 8, 2006 If $row['payment'] holds said value, something like....[code]<input type='radio'<?php ($row['payment'] == 'Cash') ? echo 'checked="checked" : echo ''; ?> name='paymentMode' value='Cash'>Cash<input type='radio'<?php ($row['payment'] == 'Credit') ? echo 'checked="checked" : echo ''; ?> name ='paymentMode' value='CreditCard'>Credit Card<input type='radio'<?php ($row['payment'] == 'Cheque') ? echo 'checked="checked" : echo ''; ?> name ='paymentMode' value='Cheque'>[/code]should do it. Link to comment https://forums.phpfreaks.com/topic/9288-displaying-update/#findComment-34226 Share on other sites More sharing options...
takeiteasy Posted May 8, 2006 Author Share Posted May 8, 2006 i've tried your solution but it still can't work. The radio buttons are still not checked. Any other soultions? Thanks! Link to comment https://forums.phpfreaks.com/topic/9288-displaying-update/#findComment-34228 Share on other sites More sharing options...
takeiteasy Posted May 9, 2006 Author Share Posted May 9, 2006 I have tried this but still not working...can someone help?[code]<?php $ca = $nets = $cc = ''; ?> <?php if ($paymentMode == 'Cash') { $ca = ' checked'; } else if ($paymentMode == 'Nets') { $nets = 'checked'; } else { $cc = 'checked'; } } ?> <input type='radio' name='paymentMode' value='Cash' echo $ca;>Cash <input type='radio' name ='paymentMode' value='Nets' echo $nets;>Nets <input type='radio' name ='paymentMode' value='Cheque' echo $cc;>Cheque [/code] Link to comment https://forums.phpfreaks.com/topic/9288-displaying-update/#findComment-34549 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.