Jump to content


Photo

Cant find where the error in my coding is


  • Please log in to reply
1 reply to this topic

#1 OriginalSunny

OriginalSunny
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts

Posted 14 March 2006 - 09:59 PM

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:

elseif($field == "cc_exp")
{
echo "<tr><td style=\"text-align: right;
font-weight: bold\">Expiration Date</td>
<td><select name='cc_exp_mo'>";
for($n=1;$n<=12;$n++)
{
echo " <option value='$n'>$n\n";
}
echo "</select>\n";
echo "<select name='cc_exp_da'>";
for($n=1;$n<=31;$n++)
{
echo " <option value='$n'>$n\n";
}
echo "</select>\n";
echo "<select name='cc_exp_yr'>";
$start_yr = date("Y",$today);
for($n=$start_yr;$n<=$start_yr+5;$n++)
{
echo " <option value='$n'>$n\n";
}
echo "</select>\n";
}


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.

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 14 March 2006 - 10:18 PM

Change:

for($n=$start_yr;$n<=$start_yr+5;$n++)

to:

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

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users