Thanks for your reply devinemke
<?php
/**
* function dateconvert
* CREATE TABLE `bousers` (
`BOUID` bigint(20) NOT NULL auto_increment,
`BOULOGIN` varchar(50) NOT NULL default '',
`BOUFNAME` varchar(50) NOT NULL default '',
`BOULNAME` varchar(50) NOT NULL default '',
`BOUPWD` varchar(50) NOT NULL default '',
`BOUISACTIVE` char(1) NOT NULL default '',
`BOUTYPE` varchar(10) NOT NULL default '',
`BOUdate` date default NULL,
PRIMARY KEY (`BOUID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
#
# Dumping data for table bousers
#
INSERT INTO `bousers` VALUES (1,'admin','john','john','admin','Y','Admin','2007-05-01');
INSERT INTO `bousers` VALUES (6,'srikanth','srikanth','kande','srikanth','Y','Admin',NULL);
INSERT INTO `bousers` VALUES (8,'srikanthkande','srikanth','kande','srikanth','Y','Admin',NULL);
* dateconvert is a handy function to take the aches and pains out of mysqls stupidity
* by converting data from a variable (posted from a form or just stored)
* into a format mysql will be able to store and converting the
* database date back into the british standard of date month year.
* The Script accepts day.month.year or day/month/year or day-month-year.
* example:
*
* <code>
* <?php // using type 1
* $date = "19.12.2005";
* $date = dateconvert($date, 1);
* echo $date; // Would echo 2005-12-19 which is the format stored by mysql
* ?>
* </code>
*
*
* @author Chris McKee <pcdevils@gmail.com>
*
* @param string $date - Date to be converted
* @param string $func - which function is to be used (1 for input to mysql, 2 for output from mysql)
*/
function dateconvert($date,$func) {
if ($func == 1){ //insert conversion
list($day, $month, $year) = split('[/.-]', $date);
$date = "$year-$month-$day";
return $date;
}
if ($func == 2){ //output conversion
list($year, $month, $day) = split('[-.]', $date);
$date = "$day/$month/$year";
return $date;
}
}
$conn=mysql_connect("localhost","root","") or die("cannot connect");
$db=mysql_select_db("artz") or die("cannot connect".mysql_error());
$qry="SELECT BOULOGIN,BOUPWD,BOUTYPE,BOUdate FROM bousers";
$res=mysql_query($qry);
while($row=mysql_fetch_array($res))
{
$date=$row['BOUdate'];
echo $date;
$two=2;
echo "<br>";
// using type 2
//$date = $row['date']; //your mysql date
$realdate = dateconvert($date,$two);
echo $realdate; // would display 19/12/2005
}
?>
i wrote the above function but it is displaying the following Notice
Notice: Undefined offset: 2 in d:\easyphp1-8\www\v1.2.5\mysql_tbl.php on line 60
Notice: Undefined offset: 1 in d:\easyphp1-8\www\v1.2.5\mysql_tbl.php on line 60
//
Notice: Undefined offset: 2 in d:\easyphp1-8\www\v1.2.5\mysql_tbl.php on line 60
Notice: Undefined offset: 1 in d:\easyphp1-8\www\v1.2.5\mysql_tbl.php on line 60
//
how to get rid of them