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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.