Jump to content

If statement


capcu

Recommended Posts

Hello,I'm really new to php. What I'm trying to do is if the two variables equal eachother than I only want to show one of the variables (StartDate). $event ->StartDate==$event ->EndDate ; Thanks for the help!

Link to comment
Share on other sites

what are you having trouble with? Are you familiar with conditional statements/logic?http://www.w3schools.com/php/php_if_else.asp

Link to comment
Share on other sites

That's the thing. I don't know what code you're using to "show" the dates, so I have no idea what to tell you. As a rule, people get better results here if they post the relevant code they are confused about. We probably don't need to see your whole script, just the part with the problem you need to solve.

Link to comment
Share on other sites

You could invert the conditon - always display the start date, and if the dates are NOT the same, display the end date as well, e.g.

//Do whatever you do to "show" the date e.g. "echo $event->StartDate;"if ($event->StartDate !== $event->EndDate) {//Do whatever you need to do to also "show" the end date, including outputting a separator, e.g. "echo '-', $event->EndDate;"}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...