For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > June 2007 > If, And, Or code for data entry









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author If, And, Or code for data entry
jcage@lycos.com

2007-06-13, 9:58 pm

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.<br />'
.'Please click the browser BACK button, fill in a Complete/
Resolved date and try again.';
exit;
}

jcage@lycos.com

2007-06-14, 3:59 am

On Jun 13, 7:23 pm, j...@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.<br />'
> .'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.<br />'
.'Please click the browser BACK button, fill in the date and
try again.';
exit;
}

Norman Peelman

2007-06-14, 3:59 am

jcage@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.<br />'
> .'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
Gordon Burditt

2007-06-14, 3:59 am

>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.<br />'
> .'Please click the browser BACK button, fill in a Complete/
>Resolved date and try again.';
> exit;
> }
>



jcage@lycos.com

2007-06-16, 3:59 am

On Jun 13, 9:04 pm, gordonb.ic...@burditt.org (Gordon Burditt) wrote:[color=darkred]
>
> The variable passed to PHP is $_GET['datecomp'] or $_POST['datecomp'],
> not $datecomp. (register_globals is evil and should be turned off).
>
>
> There's no meaning to a subexpression like: "Complete" or "Resolved".
> Think of it as: If status is Complete or status is Resolved, then ....
>
>
>
> if (isset($_GET['datecomp'] && ($_GET['status'] == "Complete" || $_GET['status'] == "Resolved"))
>


Thanks very much for your help guys - appreciate it!

Adposterjo

2007-06-17, 12:29 am

Paula Abdul and Jennifer Aniston , Lesbian Girl Sex!
Idon

2007-06-20, 12:09 pm

Shania Twain , Beef Humping Studs!
http://www.shockingtheworld.com/Watch?q=1673286

Ashlee Simpson changing her dirty panties!
http://www.shockingtheworld.com/watch?id=1673286

Britney Spears Pool Party Sex!
http://www.shockingtheworld.com/player.wmv?vid=1673286

Jessica Simpson Big Tit Movies!
http://www.shockingtheworld.com/Player.wmv?q=1673286

Laetitia Casta , Pornstar MPGS!
http://www.shockingtheworld.com/Pla....mpeg?q=1673286

star war video game google gratis musica free sex movie adult video planet foto gratis travestis
hot on web video anime porn sample video denver movie listing bold britney head spear download hardcore movies free
amateur movie download mature world free porno movie catholic movie review lyric to caught up by usher epic movie sound track
gay movie sex free lesbian movie download big home video video sexo maduras gratis clip porn private

michael jackson dance
mature blowjob movie
free facial cumshot movie
video espaƱolas gratis
funny clean video clip
free porno movie manga xxx
foto gratis de transexuales
funny film clip
clip hurley youtube
accessory car ipod video
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com