raghavendra Posted June 27, 2008 Share Posted June 27, 2008 Hi I am raghavendra i have problem in php code ....I wanted to get the data which is stored in mysql example date .....using php i wanted this date to be divided into day month and year wise and this output should be shown in xml..... could any one help me please.............. Link to comment https://forums.phpfreaks.com/topic/112153-regarding-php-and-mysql-urgent-please/ Share on other sites More sharing options...
PC Nerd Posted June 27, 2008 Share Posted June 27, 2008 Im not goign to code the entire thing for you here, however youll want somethign with the following flow: connect to mysql run query("SELECT Date FROM <TableName> WHERE <condition>") then fetch the data: mysql_fetch_assoc($QueryVar); then youll want to be displaying that using somethign like: date("Y/M/D", $QUERYARRAY['Date']); double check the Date function so you knwo what format you want to output to etc. Theres plenty of references on MySQL and PHP out there, just google: "PHP, querying mysql" or somethign to get the answer. * Most people here wont be coding the entire thing for you unless youve got somethign youve attempted etc. So look into that. * if its really that urgent and you cant code it then post in the freelancing section for such a feature. gdlk Link to comment https://forums.phpfreaks.com/topic/112153-regarding-php-and-mysql-urgent-please/#findComment-575796 Share on other sites More sharing options...
xyn Posted June 27, 2008 Share Posted June 27, 2008 Connection.php <?php $host ="localhost"; $user ="USERNAME"; $pass ="PASSWORD"; $data ="test_db"; # database name. $connect =mysql_connect($host, $user, $pass); $database =mysql_select_db($data, $connect); if(!$connect||!$database)die("Database cannot connect..."); ?> date_page.php <?php include_once 'Connection.php'; $sql =mysql_query(" select `date_field` from `database` where `field` ='this_value' "); #query $result =mysql_fetch_array($sql,MYSQL_NUM); # 1 record? no need to overkill use a number array. #windows user: (windows doesn't like dates before 1970) function my_datetime($date){ $datetime =explode(" ",$date); $date =explode("-",$datetime[0]); $newdate[] =$date[2]; $newdate[] =$date[1]; $newdate[] =$date[0]; return implode("-",$newdate)." {$datetime[1]}"; } print my_datetime($result[0]); # *nix user: (unix is better than windows) print date("d-m-Y, H:i:s",strtotime($result[0])); ?> this will return: windows: dd-mm-yyyy 00:00:00 unix: dd-mm-yyyy, 00:00:00 check http://php.net/date Link to comment https://forums.phpfreaks.com/topic/112153-regarding-php-and-mysql-urgent-please/#findComment-575806 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.