Hi,
I'm creating a page for adding articles which will be coming from several places, some commissioned for the site, others from the printed magazine. In all cases we need the option to archive them.
If the article is to be archived, the user must specify if it's from the printed version, if this is the case it must have either an edition number or a month & year of publication. I've tried every which way to get it working, but either it errors when it shouldn't, or doesn't when it should!
The logic:
If the flag for being printed is set:
If the edition number is blank AND the month and year are '0', it should error
If the edition number is blank AND month and year are NOT '0', it should be OK
If the edition number is NOT blank AND month and year are NOT '0', it should be OK
If the edition number is NOT blank AND month and year are '0', it should be OK
I just can't make the damn thing work, here's my code (latest version - aiming for logic rather than style here)
I'm also echoing out all the values afterwards, to see if something's not passing correctly, but it is.
The problem seems to be with the dates, as despite the fact that they're not selected (therefore requiring an edition number) it's still going through to the db.
This line has problems, as while both variables ARE '0', $nodate is not becoming true:
if ($edmonth == '0' && $edyear =='0') { $nodate = true;}
if ($type == '4' && $printed == '1') //if it's an archive article and from a printed version
{
if (trim($ednum) == '' || trim($ednum) == '0')
{
$noedition = true;
}
if ($edmonth == '0' && $edyear =='0')
{
$nodate = true;
}
if ($noedition == true and $nodate == true)
{
$errorlist[] = 'You have specified a printed archive article, but not specified which edition. Please add an edition number and/or a month and year of first printing';
}
}
Where am I going wrong!?