cjkeane Posted February 28, 2011 Share Posted February 28, 2011 Hi. I have form data being echoed in several date fields on a form. As soon as the form is submitted and the page refreshes, any field i have set as date datatypes, automatically put 0000-00-00. i have every form field echo so that the data is visible after submission but i do not want any date field to display 0000-00-00. i'm currently using this code on a date of birth field, but it still doesnt prevent 0000-00-00 from being displayed. i'd appreciate any assistance you may offer. thanks <?php if ($DateOfBirth != "0000-00-00"); echo $DateOfBirth ?> Quote Link to comment https://forums.phpfreaks.com/topic/229143-php-snipped-to-not-echo-data/ Share on other sites More sharing options...
Muddy_Funster Posted March 1, 2011 Share Posted March 1, 2011 your if is malformed: <php if($DateOfBirth != '0000-00-00'){echo $DateOfBirth;} ?> is how it should look. When writing an if I find it helps to think of the { as being "then begin" and the } as "end" so when you run through the logic you remember where to put them. e.g. IF variable called DateOfBirth does not equal the value 0000-00-00 then begin show message on screen displaying the contents of the DateOfBirth variable end Quote Link to comment https://forums.phpfreaks.com/topic/229143-php-snipped-to-not-echo-data/#findComment-1181168 Share on other sites More sharing options...
cjkeane Posted March 1, 2011 Author Share Posted March 1, 2011 thanks. everything works now. i knew it was something simple. Quote Link to comment https://forums.phpfreaks.com/topic/229143-php-snipped-to-not-echo-data/#findComment-1181307 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.