OriginalSunny Posted March 14, 2006 Share Posted March 14, 2006 Hi i am having a problem trying to sort out the my date of birth section in the form i want the user to fill out. I have used the following code to do my credit card valuation:[i] elseif($field == [b]"cc_exp"[/b]) { echo "<tr><td style=\"text-align: right; font-weight: bold\">Expiration Date</td> <td><select name=[b]'cc_exp_mo'[/b]>"; for($n=1;$n<=12;$n++) { echo " <option value='$n'>$n\n"; } echo "</select>\n"; echo "<select name=[b]'cc_exp_da'[/b]>"; for($n=1;$n<=31;$n++) { echo " <option value='$n'>$n\n"; } echo "</select>\n"; echo "<select name=[b]'cc_exp_yr'[/b]>"; $start_yr = date("Y",$today);[b] for($n=$start_yr;$n<=$start_yr+5;$n++)[/b] { echo " <option value='$n'>$n\n"; } echo "</select>\n"; }[/i]This works fine. However to do date of birth u need to change the code above which is in bold. The first problem is that if "cc_exp" on the first line and "cc_exp_mo", "cc_exp_da" and "cc_exp_yr" to "DOB", "dob_mo", dob_da", dob_yr" it comes up with the error 'no such field cc_exp_mo'.The next problem is when i change ($n=$start_yr;$n<=$start_yr+5;$n++) to either of the following it doesnt work:for($n=$start_yr;$n<=$start_yr-50;$n--)for($n=$start_yr;$n<=$start_yr-50;$n++)for($n=$start_yr;$n<=$start_yr+50;$n--)It currently shows the dates between 2006 and 2011. I need it to show the dates between 2006 and 50 yrs before 2006.So what should i be doing here??Thanks. Link to comment https://forums.phpfreaks.com/topic/4981-cant-find-where-the-error-in-my-coding-is/ Share on other sites More sharing options...
hitman6003 Posted March 14, 2006 Share Posted March 14, 2006 Change:[code]for($n=$start_yr;$n<=$start_yr+5;$n++)[/code]to:[code]//for descending yearsfor($n=$start_yr;$n>=$start_yr-50;$n--)//for ascending years:for($n=$start_yr-50;$n>=$start_yr;$n++)[/code] Link to comment https://forums.phpfreaks.com/topic/4981-cant-find-where-the-error-in-my-coding-is/#findComment-17562 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.