capcu Posted April 26, 2013 Share Posted April 26, 2013 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 More sharing options...
jeffman Posted April 26, 2013 Share Posted April 26, 2013 (edited) The basic idea looks like this: if ($event->StartDate == $event->EndDate){ // do something;} I do not know what you mean by "show" Edited April 26, 2013 by Deirdre's Dad Link to comment Share on other sites More sharing options...
thescientist Posted April 26, 2013 Share Posted April 26, 2013 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 More sharing options...
capcu Posted April 26, 2013 Author Share Posted April 26, 2013 Basically I don't want the date to show up twice so if the dates are both April 26 I only want to see ONE April 26 not April 26 April 26. Link to comment Share on other sites More sharing options...
jeffman Posted April 26, 2013 Share Posted April 26, 2013 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 More sharing options...
boen_robot Posted April 27, 2013 Share Posted April 27, 2013 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now