php连接数据库,日期截取

来源:互联网 发布:ppt转换视频软件 编辑:程序博客网 时间:2024/05/17 05:03

co.php:

function hh(){
 $conn = new com("ADODB.Connection");
 $connstr = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" . realpath("#database#/#database#.mdb ");
 $conn->Open($connstr);
return $conn;
}

<?php
include "inc/co.php";
$conn=hh();
?>

 

日期:

$newstime=$rs->Fields("newstime");
echo date("Y/m/d",strtotime($newstime));

 

读取数据:

<?php
$rs=new com("adodb.recordset");
$sql="select * from news where news_class_id=14 order by newstime desc";
$rs->Open($sql,$conn,1,1);
if (!$rs->eof){
 for($i=0;$i<=6;$i++){
  ?>


<?=$rs->Fields("newstitle") ?>

 

  <?php
  $rs->movenext;
  if($rs->eof){
  break;
  }
 }
}
$rs->close;
$rs=null;
?>

原创粉丝点击