Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to insert date in mysql using php

$sample1 = "insert into table (id,date) value(1,'".date("Y-m-d H:i:s")."')";

$sample2 = "insert into user (name,date,created_by) value('perasuah negara', now(), 1)"
Comment

insert date of birth on the database using php

<!DOCTYPE html>
<html>
<head>
   <title></title>
</head>
<body>
<form method="POST" action="">
<select name="Year">
  <option value="">Select year</option>
  <?php for ($i = 1980; $i < date('Y'); $i++) : ?>
  <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
  <?php endfor; ?>
</select>
<select name="Month">
  <option value="">Select month</option>
  <?php for ($i = 1; $i <= 12; $i++) : ?>
  <option value="<?php echo ($i < 10) ? '0'.$i : $i; ?>"><?php echo $i; ?></option>
  <?php endfor; ?>
</select>
<select name="Date">
  <option value="">Select date</option>
  <?php for ($i = 1; $i <= 31; $i++) : ?>
  <option value="<?php echo ($i < 10) ? '0'.$i : $i; ?>"><?php echo $i; ?></option>
  <?php endfor; ?>
</select>
   <input type="submit" name="sub">
</form>
</body>
</html>
<?php
$conn = mysqli_connect("localhost","root","","getdob");
if(isset($_POST['sub']))
{
$Year = $_POST['Year'];
$Month = $_POST['Month'];
$Date = $_POST['Date'];
if ($Year != '' && $Month != '' && $Date != '') 
   {
   $date = $Year.'-'.$Month.'-'.$Date;
   $sql="INSERT INTO dob VALUES  (Null,'$date')";
   if (mysqli_query($conn,$sql))
   {
      echo "Record added!";
   }
   else
   {
      echo "Error!!!";
   }
   }
else
   {
      echo "Please Select Day, Month and Year!!!";
   }   
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: running laravel queues in shared hosting 
Php :: sum of multidimensional array in php 
Php :: string array to array in php 
Php :: php post request 
Php :: php query pdo 
Php :: laravel select max value 
Php :: destory session in laravel 
Php :: symfony migration down 
Php :: tableau aléatoire php 
Php :: how to check if key is present in json in php 
Php :: settimezone in php 
Php :: php cookie 
Php :: laravel enum validation 
Php :: int to char php 
Php :: set value in session php 
Php :: wordpress post types supports thumbnail 
Php :: php pdo error handling 
Php :: laravel get last id 
Php :: how to display the site tagline in wordpress 
Php :: laravel insert array 
Php :: symfony set timezone 
Php :: laravel Service Unavailable 
Php :: Laravel eloquent restore soft delete 
Php :: DateTime and Timestamps 
Php :: get post by meta value 
Php :: add shortcode in wordpress 
Php :: Laravel Eloquent Query Using WHERE with OR AND OR? 
Php :: pretty json php 
Php :: docker : from php alpine 
Php :: laravel query order by relation 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =