By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,748 Members | 2,043 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,748 IT Pros & Developers. It's quick & easy.

html display for date with null value

P: n/a
I have some date fields which in some records will have NULL value.

I am trying to show nothing in the HTML display.

IF
<?
$date3=$myrow[when3'];
?>
<p><?=$date3?><p>
The html display is 0000-00-00 if there is no date value in the db table. I
am trying to have nothing displayed for $date3

IF
<?
$date3 = $myrow['when3'];
if($date3="0000-00-00"){$date3="";}
else {$date3=$date3;}
?>
<p><?=$date3?><p>
Nothing is displayed in the page even if a date value has been inserted into
the db table

How can I achieve this?

Louise

Jul 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
you only have a single '=' in the 'if' statement
This is assigning the value, not comparing it - will always return TRUE

=)
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:9j********************************@4ax.com...
On Sun, 17 Aug 2003 07:01:22 GMT, "boclair" <bo*****@bigpond.net.au> wrote:
I have some date fields which in some records will have NULL value.

I am trying to show nothing in the HTML display.

IF
<?
$date3=$myrow[when3'];
?>
<p><?=$date3?><p>
The html display is 0000-00-00 if there is no date value in the db table. Iam trying to have nothing displayed for $date3

IF
<?
$date3 = $myrow['when3'];
if($date3="0000-00-00"){$date3="";}
else {$date3=$date3;}
?>
<p><?=$date3?><p>
Nothing is displayed in the page even if a date value has been inserted intothe db table

How can I achieve this?
Sounds like it's your data in the table that's wrong in the first place;

if your date really is NULL, you should get an empty string back.

What database are you using, what datatype is the column, and is it really NULL or actually set to 0000-00-00?

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

Jul 16 '05 #2

P: n/a
> > ><?
$date3 = $myrow['when3'];
if($date3="0000-00-00"){$date3="";}
else {$date3=$date3;}
?>
<p><?=$date3?><p>


"Jeremy Elliot" <je**********@paradise.net.nz> wrote in message
news:zy*********************@news02.tsnz.net... you only have a single '=' in the 'if' statement
This is assigning the value, not comparing it - will always return TRUE

=)


Jeremy, I had a very bad day. I was not only misreading tables but I was
doing things like this, failing to match brackets and on and on. Somedays I
would rather have any job but the one I've got.
Thanks, Louise

Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.