0

Hope someone can help me with the folowing.

I have a date in a data table Works perfect to put a date in the table.

But when i delete the date and the update with an empty date it wil update me the date of today.
But i want it empty

<?php
if(isset($_POST['zenden']))
{

    if(empty($_POST['datum_huwelijk']))
    {
                $datum_huwelijk = null; 
    }

    if($_POST['datum_huwelijk'] != "" || $_POST['datum_huwelijk'] != " " || $_POST['datum_huwelijk'] != "  ")
    {
        $datum_huwelijk = new DateTime($_POST['datum_huwelijk']);
        $datum_huwelijk = date_format($datum_huwelijk, 'Y-m-d');
    }
        $con = mysql_connect("localhost","login-name","password");
        if (!$con)
        {
            die('Could not connect: ' . mysql_error());
        }

                        mysql_select_db("stamboom", $con);

                        $updatequeryy = "UPDATE stamboom_dohmen SET  datum_huwelijk='$datum_huwelijk'
                        WHERE id='".$_SESSION['id_te_bewerken_persoon']."'";
                        mysql_query($updatequeryy) or die (mysql_error()); 
}

?>
<form action="" method="post" name="myform" enctype="multipart/form-data">
   <div style="padding:7px; height:12px; width:210px; background-color:#000; color:#FFF; font-size:10px; text-align:right;
       float:left;" >Date:
   </div>
      <input type="text"  readonly="readonly" name="datum_huwelijk" value="<?php 
          if($rowman['datum_huwelijk']=='0000-00-00')
          {
          echo "";
          }
          else
            {
                $dat_huwe = new DateTime($rowman['datum_huwelijk']);
                $dat_huwel = date_format($dat_huwe, 'd-m-Y'); echo $dat_huwel;
                } ?>" size="15" style="font-size:12px; margin-left:3px; float:left;  height:20px;  cursor:pointer;"
                title="DD-MM-YYYY." onClick="javascript:NewCssCal('demo4')" id="demo4">
              <img src="../images/cal.gif" alt="" onClick="javascript:NewCssCal('demo4')" style="cursor:pointer;
                  margin-left:10px; float:left;">&nbsp;&nbsp;&nbsp;
              <input type="button" style="margin-left:10px; float:left;"
              onclick="document.getElementById('demo4').value=''" value="Delete date">

              <input type="submit" style="width:100px;"  name="zenden" value="Alles verzenden"/>
 </form>

When i write

onclick="document.getElementById('demo4').value='0000-00-00'"

It works but not when i write

onclick="document.getElementById('demo4').value=''"

thanks in advice John

2
Contributors
3
Replies
15
Views
3 Years
Discussion Span
Last Post by johnnyd1963
0

no the table is alright i set it as date so as i said i can ad new dates and update a new date. but not update it to NULL.

Edited by johnnyd1963

0

i have found the problem. had a conflict with another piece of javascript.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.