QUOTE(CharlesEF @ Dec 29 2023, 04:03 AM)
I have not heard from you about the test results. But try this:
CODE
<?php
session_start();
$con=mysqli_connect("localhost", "root", "", "test");
if(isset($_POST['save']))
{
$name=$_POST['name'];
$dob=empty($_POST['dob']) ? "NULL" : "'{$_POST['dob']}'";
$query="INSERT INTO date(name,date) VALUES('$name', $dob)";
$query_run = mysqli_query($con, $query);
$_SESSION['status']="Date values inserted";
}
else
{
$_SESSION['status']="Date values Inserting failed";
}
?>
Hi Charles
Let me wish one and all of this forum a very happy new year in advance
Its my hobby to design in PHP MYSQL. I learnt from the online resources like our forum, youtube videos hence you may find lots of errors in my approach.
my happiness of putting down the above error evaporates with a fresh error with select query to display records.
Whereever NULL values in the table cell, select query fetching and displaying as 1970-01-01. The following is the code,
$conn = new mysqli("localhost", "root", "", "test");
$sql="select * from date";
$res=$conn->query($sql);
while($row=$res->fetch_assoc()){
?>
<tr>
<td>
if(is_null($row['dob'])){
echo '--';
}else{
echo 'date("d-m-Y",strtotime($row['dob']))';
}?>
</td>
</tr>
With the above If condition, the display of 1970-01-01 is stopped where there is a NULL in table cell but when there is a date, that also showing as blank.
Please guide me to overcome this issue.
Regards