html display for date with null value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • boclair

    html display for date with null value

    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



  • Jeremy Elliot

    #2
    Re: html display for date with null value

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

    =)


    "Andy Hassall" <andy@andyh.co. uk> wrote in message
    news:9jmujv829i jd27t02nrstec4p f2pd9357m@4ax.c om...[color=blue]
    > On Sun, 17 Aug 2003 07:01:22 GMT, "boclair" <boclair@bigpon d.net.au>[/color]
    wrote:[color=blue]
    >[color=green]
    > >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=$myro w[when3'];
    > >?>
    > ><p><?=$date3?> <p>
    > >The html display is 0000-00-00 if there is no date value in the db table.[/color][/color]
    I[color=blue][color=green]
    > >am trying to have nothing displayed for $date3
    > >
    > >IF
    > ><?
    > >$date3 = $myrow['when3'];
    > >if($date3="000 0-00-00"){$date3=""; }
    > >else {$date3=$date3; }
    > >?>
    > ><p><?=$date3?> <p>
    > >Nothing is displayed in the page even if a date value has been inserted[/color][/color]
    into[color=blue][color=green]
    > >the db table
    > >
    > >How can I achieve this?[/color]
    >
    > Sounds like it's your data in the table that's wrong in the first place;[/color]
    if[color=blue]
    > 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[/color]
    really[color=blue]
    > NULL or actually set to 0000-00-00?
    >
    > --
    > Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
    > Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)[/color]


    Comment

    • boclair

      #3
      Re: html display for date with null value

      > > ><?[color=blue][color=green][color=darkred]
      > > >$date3 = $myrow['when3'];
      > > >if($date3="000 0-00-00"){$date3=""; }
      > > >else {$date3=$date3; }
      > > >?>
      > > ><p><?=$date3?> <p>[/color][/color][/color]


      "Jeremy Elliot" <jeremyelliot@p aradise.net.nz> wrote in message
      news:zyJ%a.1203 2$9f7.1383114@n ews02.tsnz.net. ..[color=blue]
      > you only have a single '=' in the 'if' statement
      > This is assigning the value, not comparing it - will always return TRUE
      >
      > =)[/color]

      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





      Comment

      Working...