I am making a form, to register a product, in mysql
I have id
, sku
, fecha_entrada
and fecha_salida
and other columns.
When I register the product I only want the date to be inserted automatically in date_entry, I am using NOW()
and if it inserts the date and time but in both fields, as well fecha_entrada
as in fecha_salida
. I just need it to be entered in date_entry.
Thank you
This is my code for product registration:
$consulta="SELECT sku FROM movimientos WHERE sku='$sku'";
$sql=mysqli_query ($conexion, $consulta);
//mysqli_close($conexion);
if(mysqli_num_rows($sql) > 0) {
echo 'Ya existe la clave';
}
else{
$sql="INSERT INTO movimientos
(sku, nombre, descripcion, fecha_entrada, cantidad, costo, precio)
VALUES ('$sku',
'$nombre',
'$descripcion',
NOW(), /*Introduce la fecha y hora actual del registro*/
'$cantidad',
'$costo',
'$precio')";
$ejecutar=mysqli_query($conexion,$sql);
MariaDB [abarrotes]> describe movimientos;
+---------------+---------------+------+-----+---------------------+------------
----+
| Field | Type | Null | Key | Default | Extra
|
+---------------+---------------+------+-----+---------------------+------------
----+
| id | int(11) | NO | PRI | NULL | auto_increm
ent |
| sku | int(11) | NO | | NULL |
|
| nombre | varchar(25) | NO | | NULL |
|
| descripcion | varchar(100) | NO | | NULL |
|
| fecha_entrada | timestamp | NO | | current_timestamp() |
|
| fecha_salida | timestamp | NO | | current_timestamp() |
|
| cantidad | int(11) | NO | | NULL |
|
| costo | decimal(12,2) | NO | | NULL |
|
| precio | decimal(12,2) | NO | | NULL |
|
+---------------+---------------+------+-----+---------------------+------------
----+
9 rows in set (0.007 sec)
MariaDB [abarrotes]>