Jump to content

Archived

This topic is now archived and is closed to further replies.

OriginalSunny

Cant find where the error in my coding is

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Change:

[code]for($n=$start_yr;$n<=$start_yr+5;$n++)[/code]

to:

[code]//for descending years
for($n=$start_yr;$n>=$start_yr-50;$n--)

//for ascending years:
for($n=$start_yr-50;$n>=$start_yr;$n++)[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.