Jump to content

PHP snipped to not echo data


cjkeane

Recommended Posts

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 ?>

 

Link to comment
https://forums.phpfreaks.com/topic/229143-php-snipped-to-not-echo-data/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.