If, And, Or code for data entry

I have a drop down box with 'Incomplete', 'Resolved' and 'Complete' as
part of my $status variable on a form and a text box called
'$datecomp' that passes the data from both variables to a MySQL
database.

How might I include an 'if' statement where if the drop down selection
for variable $datecomp is 'Incomplete' or 'Resolved', an error message
is displayed on the data entry confirmation page that requests the
user to click their browser 'back' button and enter a date in the
'datecomp' field? I was trying to modify the following code but so
far, without any luck. In other words, if 'status' = Complete or
Resolved, trigger the error on the confirmation page where a user
clicks their back button and either enters a date in the datecomp
field OR leaves the drop down box as Incomplete.

thanks,
John

if (!$datecomp || and $status="Complete" or "Resolved")
{
echo 'You must enter a DATE for items marked Complete or
Resolved.
'
.'Please click the browser BACK button, fill in a Complete/
Resolved date and try again.';
exit;
}
jcage [ Do, 14 Juni 2007 04:23 ] [ ID #1737648 ]

Re: If, And, Or code for data entry

On Jun 13, 7:23 pm, j... [at] lycos.com wrote:
> I have a drop down box with 'Incomplete', 'Resolved' and 'Complete' as
> part of my $status variable on a form and a text box called
> '$datecomp' that passes the data from both variables to a MySQL
> database.
>
> How might I include an 'if' statement where if the drop down selection
> for variable $datecomp is 'Incomplete' or 'Resolved', an error message
> is displayed on the data entry confirmation page that requests the
> user to click their browser 'back' button and enter a date in the
> 'datecomp' field? I was trying to modify the following code but so
> far, without any luck. In other words, if 'status' = Complete or
> Resolved, trigger the error on the confirmation page where a user
> clicks their back button and either enters a date in the datecomp
> field OR leaves the drop down box as Incomplete.
>
> thanks,
> John
>
> if (!$datecomp || and $status="Complete" or "Resolved")
> {
> echo 'You must enter a DATE for items marked Complete or
> Resolved.
'
> .'Please click the browser BACK button, fill in a Complete/
> Resolved date and try again.';
> exit;
> }


Solved this puzzle (though it may not be the best example of code
writing) and thought I'd put the solution here in hopes of helping
someone else in a similar bind.. :-)

if ((($status == "Complete") or ($status == "Resolved") and ($datecomp
== "")))
{
echo 'All items marked COMPLETE or RESOLVED must have a date
entered.
'
.'Please click the browser BACK button, fill in the date and
try again.';
exit;
}
jcage [ Do, 14 Juni 2007 05:56 ] [ ID #1737649 ]

Re: If, And, Or code for data entry

jcage [at] lycos.com wrote:
> I have a drop down box with 'Incomplete', 'Resolved' and 'Complete' as
> part of my $status variable on a form and a text box called
> '$datecomp' that passes the data from both variables to a MySQL
> database.
>
> How might I include an 'if' statement where if the drop down selection
> for variable $datecomp is 'Incomplete' or 'Resolved', an error message
> is displayed on the data entry confirmation page that requests the
> user to click their browser 'back' button and enter a date in the
> 'datecomp' field? I was trying to modify the following code but so
> far, without any luck. In other words, if 'status' = Complete or
> Resolved, trigger the error on the confirmation page where a user
> clicks their back button and either enters a date in the datecomp
> field OR leaves the drop down box as Incomplete.
>
> thanks,
> John
>
> if (!$datecomp || and $status="Complete" or "Resolved")
> {
> echo 'You must enter a DATE for items marked Complete or
> Resolved.
'
> .'Please click the browser BACK button, fill in a Complete/
> Resolved date and try again.';
> exit;
> }
>

if (!$datecomp && ($status == 'Complete' || $status == 'Resolved'))


....use '=' for assignment and '==' for comparison.

Norm
Norman Peelman [ Do, 14 Juni 2007 06:03 ] [ ID #1737650 ]

Re: If, And, Or code for data entry

>I have a drop down box with 'Incomplete', 'Resolved' and 'Complete' as
>part of my $status variable on a form and a text box called
>'$datecomp' that passes the data from both variables to a MySQL
>database.

The variable passed to PHP is $_GET['datecomp'] or $_POST['datecomp'],
not $datecomp. (register_globals is evil and should be turned off).

>How might I include an 'if' statement where if the drop down selection
>for variable $datecomp is 'Incomplete' or 'Resolved', an error message
>is displayed on the data entry confirmation page that requests the
>user to click their browser 'back' button and enter a date in the
>'datecomp' field? I was trying to modify the following code but so
>far, without any luck. In other words, if 'status' = Complete or
>Resolved, trigger the error on the confirmation page where a user
>clicks their back button and either enters a date in the datecomp
>field OR leaves the drop down box as Incomplete.

There's no meaning to a subexpression like: "Complete" or "Resolved".
Think of it as: If status is Complete or status is Resolved, then ....

>thanks,
>John
>
>if (!$datecomp || and $status="Complete" or "Resolved")

if (isset($_GET['datecomp'] && ($_GET['status'] == "Complete" || $_GET['status'] == "Resolved"))

> {
> echo 'You must enter a DATE for items marked Complete or
>Resolved.
'
> .'Please click the browser BACK button, fill in a Complete/
>Resolved date and try again.';
> exit;
> }
>
gordonb.ic647 [ Do, 14 Juni 2007 06:04 ] [ ID #1737651 ]

Re: If, And, Or code for data entry

On Jun 13, 7:23 pm, j... [at] lycos.com wrote:
> I have a drop down box with 'Incomplete', 'Resolved' and 'Complete' as
> part of my $status variable on a form and a text box called
> '$datecomp' that passes the data from both variables to a MySQL
> database.
>
> How might I include an 'if' statement where if the drop down selection
> for variable $datecomp is 'Incomplete' or 'Resolved', an error message
> is displayed on the data entry confirmation page that requests the
> user to click their browser 'back' button and enter a date in the
> 'datecomp' field? I was trying to modify the following code but so
> far, without any luck. In other words, if 'status' = Complete or
> Resolved, trigger the error on the confirmation page where a user
> clicks their back button and either enters a date in the datecomp
> field OR leaves the drop down box as Incomplete.
>
> thanks,
> John
>
> if (!$datecomp || and $status="Complete" or "Resolved")
> {
> echo 'You must enter a DATE for items marked Complete or
> Resolved.
'
> .'Please click the browser BACK button, fill in a Complete/
> Resolved date and try again.';
> exit;
> }


Solved this puzzle (though it may not be the best example of code
writing) and thought I'd put the solution here in hopes of helping
someone else in a similar bind.. :-)

if ((($status == "Complete") or ($status == "Resolved") and ($datecomp
== "")))
{
echo 'All items marked COMPLETE or RESOLVED must have a date
entered.
'
.'Please click the browser BACK button, fill in the date and
try again.';
exit;
}
jcage [ Do, 14 Juni 2007 05:56 ] [ ID #1737686 ]

Re: If, And, Or code for data entry

jcage [at] lycos.com wrote:
> I have a drop down box with 'Incomplete', 'Resolved' and 'Complete' as
> part of my $status variable on a form and a text box called
> '$datecomp' that passes the data from both variables to a MySQL
> database.
>
> How might I include an 'if' statement where if the drop down selection
> for variable $datecomp is 'Incomplete' or 'Resolved', an error message
> is displayed on the data entry confirmation page that requests the
> user to click their browser 'back' button and enter a date in the
> 'datecomp' field? I was trying to modify the following code but so
> far, without any luck. In other words, if 'status' = Complete or
> Resolved, trigger the error on the confirmation page where a user
> clicks their back button and either enters a date in the datecomp
> field OR leaves the drop down box as Incomplete.
>
> thanks,
> John
>
> if (!$datecomp || and $status="Complete" or "Resolved")
> {
> echo 'You must enter a DATE for items marked Complete or
> Resolved.
'
> .'Please click the browser BACK button, fill in a Complete/
> Resolved date and try again.';
> exit;
> }
>

if (!$datecomp && ($status == 'Complete' || $status == 'Resolved'))


....use '=' for assignment and '==' for comparison.

Norm
Norman Peelman [ Do, 14 Juni 2007 06:03 ] [ ID #1737687 ]

Re: If, And, Or code for data entry

>I have a drop down box with 'Incomplete', 'Resolved' and 'Complete' as
>part of my $status variable on a form and a text box called
>'$datecomp' that passes the data from both variables to a MySQL
>database.

The variable passed to PHP is $_GET['datecomp'] or $_POST['datecomp'],
not $datecomp. (register_globals is evil and should be turned off).

>How might I include an 'if' statement where if the drop down selection
>for variable $datecomp is 'Incomplete' or 'Resolved', an error message
>is displayed on the data entry confirmation page that requests the
>user to click their browser 'back' button and enter a date in the
>'datecomp' field? I was trying to modify the following code but so
>far, without any luck. In other words, if 'status' = Complete or
>Resolved, trigger the error on the confirmation page where a user
>clicks their back button and either enters a date in the datecomp
>field OR leaves the drop down box as Incomplete.

There's no meaning to a subexpression like: "Complete" or "Resolved".
Think of it as: If status is Complete or status is Resolved, then ....

>thanks,
>John
>
>if (!$datecomp || and $status="Complete" or "Resolved")

if (isset($_GET['datecomp'] && ($_GET['status'] == "Complete" || $_GET['status'] == "Resolved"))

> {
> echo 'You must enter a DATE for items marked Complete or
>Resolved.
'
> .'Please click the browser BACK button, fill in a Complete/
>Resolved date and try again.';
> exit;
> }
>
gordonb.ic647 [ Do, 14 Juni 2007 06:04 ] [ ID #1737688 ]

Re: If, And, Or code for data entry

On Jun 13, 9:04 pm, gordonb.ic... [at] burditt.org (Gordon Burditt) wrote:
> >I have a drop down box with 'Incomplete', 'Resolved' and 'Complete' as
> >part of my $status variable on a form and a text box called
> >'$datecomp' that passes the data from both variables to a MySQL
> >database.
>
> The variable passed to PHP is $_GET['datecomp'] or $_POST['datecomp'],
> not $datecomp. (register_globals is evil and should be turned off).
>
> >How might I include an 'if' statement where if the drop down selection
> >for variable $datecomp is 'Incomplete' or 'Resolved', an error message
> >is displayed on the data entry confirmation page that requests the
> >user to click their browser 'back' button and enter a date in the
> >'datecomp' field? I was trying to modify the following code but so
> >far, without any luck. In other words, if 'status' = Complete or
> >Resolved, trigger the error on the confirmation page where a user
> >clicks their back button and either enters a date in the datecomp
> >field OR leaves the drop down box as Incomplete.
>
> There's no meaning to a subexpression like: "Complete" or "Resolved".
> Think of it as: If status is Complete or status is Resolved, then ....
>
> >thanks,
> >John
>
> >if (!$datecomp || and $status="Complete" or "Resolved")
>
> if (isset($_GET['datecomp'] && ($_GET['status'] == "Complete" || $_GET['status'] == "Resolved"))
>
> > {
> > echo 'You must enter a DATE for items marked Complete or
> >Resolved.
'
> > .'Please click the browser BACK button, fill in a Complete/
> >Resolved date and try again.';
> > exit;
> > }


Thanks very much for your help guys - appreciate it!
jcage [ Fr, 15 Juni 2007 15:35 ] [ ID #1738445 ]

Re: If, And, Or code for data entry

On Jun 13, 9:04 pm, gordonb.ic... [at] burditt.org (Gordon Burditt) wrote:
> >I have a drop down box with 'Incomplete', 'Resolved' and 'Complete' as
> >part of my $status variable on a form and a text box called
> >'$datecomp' that passes the data from both variables to a MySQL
> >database.
>
> The variable passed to PHP is $_GET['datecomp'] or $_POST['datecomp'],
> not $datecomp. (register_globals is evil and should be turned off).
>
> >How might I include an 'if' statement where if the drop down selection
> >for variable $datecomp is 'Incomplete' or 'Resolved', an error message
> >is displayed on the data entry confirmation page that requests the
> >user to click their browser 'back' button and enter a date in the
> >'datecomp' field? I was trying to modify the following code but so
> >far, without any luck. In other words, if 'status' = Complete or
> >Resolved, trigger the error on the confirmation page where a user
> >clicks their back button and either enters a date in the datecomp
> >field OR leaves the drop down box as Incomplete.
>
> There's no meaning to a subexpression like: "Complete" or "Resolved".
> Think of it as: If status is Complete or status is Resolved, then ....
>
> >thanks,
> >John
>
> >if (!$datecomp || and $status="Complete" or "Resolved")
>
> if (isset($_GET['datecomp'] && ($_GET['status'] == "Complete" || $_GET['status'] == "Resolved"))
>
> > {
> > echo 'You must enter a DATE for items marked Complete or
> >Resolved.
'
> > .'Please click the browser BACK button, fill in a Complete/
> >Resolved date and try again.';
> > exit;
> > }


Thanks very much for your help guys - appreciate it!
jcage [ Fr, 15 Juni 2007 15:35 ] [ ID #1738475 ]
PHP » alt.php » If, And, Or code for data entry

Vorheriges Thema: mysql_query strangeness (misreported syntax error?)
Nächstes Thema: Removing unicode from string with php