I need to obtain only the day, extracted from a date variable, and display it, without affecting the Mysql database.
Here is the code to explain myself more:
Include file use to connect to the database: (name: conectar.i)
<?php
function Conectar()
{
if (!($Conexion=mysql_connect("localhost")))
{
echo "Error conectando a la base de datos.";
exit();
}
if (!($sql=mysql_select_db("caja",$Conexion)))
{
echo "Error seleccionando la base de datos.";
exit();
}
return $Conexion;
}
$Conexion=Conectar();
?>
This is the code of the program:
<?php
INCLUDE("conectar.i");
$result=mysql_query("select * from fecoper",$Conexion);
$row=mysql_fetch_array($result);
if ($row)
{
$fec = $row["fecope_fec"];
$day=$fec["mday"];
echo $day;
}
?>
And this is the table definitions of the database:
CREATE TABLE fecoper (
fecope_fec date NOT NULL default '0000-00-00'
) TYPE=MyISAM COMMENT='Tabla de Fecha de Operacion';
#
dump data into fecoper
#
INSERT INTO fecoper VALUES ('2003-04-03');
Any help would be appreciated.
Thanks.
Be happy. 😉