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;
?>