Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic If Else Help.

Status
Not open for further replies.

HostWeb

Technical User
Mar 9, 2005
2
GB
Hi there,

I am still getting the hang of PHP and am stuck. I have a recordset called workorderresult.

If the date value returns 0000-00-00 I need to print Still Avtive instead of 0000-00-00. Otherwise if any other value is returned besides that the print it. Here is what I have so far.... Where am I going wrong. Please help.

<?php
$comp = $row_workorderresult['completiondate'];
if (comp == date("Y-m-d",0000-00-00);{
echo "Still Active";
}
else {
echo $row_workorderresult['completiondate'];
}
?>

Can anyone help???
 
Hmm, if you are to format the date, why not do it inside your mysql database?

Converting the date there, will give you less system stress, which again will give you faster loading-times.

I however see a small typo you have:
Code:
if ([b]$[/b]comp == date("Y-m-d",0000-00-00);{
echo "Still Active";
}

eg. you lack the $ in front of the variable $comp.

Good luck!

ps. You can also echo out the variables, to check which values they give you, to ensure that your if/else will run correctly based on your logic.

Olav Alexander Mjelde
Admin & Webmaster
 
Thanks a mill. I will check it out now.

 
I also notice that you have a semi-colon at the end of the if statement. This is not needed and might cause problems for php.
Code:
if (comp == date("Y-m-d",0000-00-00);{
should be
Code:
if (comp == date("Y-m-d",0000-00-00) {

If it aint broke, redesign it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top