".$row['cat']." - Posted on ".$row['dateposted'].""; //date("D jS">
当前位置:Gxlcms > PHP教程 > PHP_SQL_数据库读取的“日期”处理

PHP_SQL_数据库读取的“日期”处理

时间:2021-07-01 10:21:17 帮助过:31人阅读

require("header.php");

    $sql = "SELECT entries.*, catetories.cat FROM entries, catetories
        WHERE entries.cat_id = catetories.id
        ORDER BY dateposted DESC
        LIMIT 1;";
        //数据库知识,$sql构建查询语句(排序后,最新日期的数组为第一个,limit 1指只取一个)$result = mysql_query($sql);
    //把查询语句$sql通过mysql_query()语句发送到数据库,并把结果(表)存在$result中$row = mysql_fetch_assoc($result);
    //把$result中的表通过mysql_fetch_assoc()方法一个个存在$row数组中echo"

.$row['id']."'>".$row['subject']."


"
; echo"In .$row['cat_id']."'>".$row['cat']." - Posted on ".$row['dateposted'].""; //date("D jS F Y g.iA",strtotime($row['dateposted']))echo"

"; echo nl2br($row['body']); //这个函数将$row['body']的内容里面的空行转换成html的
,最后一行关闭段落标签
echo"

"
; //以上涉及html代码格式,以php读取数据的方式构建html//viewentry.php 和 viewcat.php是另外的php网页,与本次测试无关require("footer.php"); ?>

直接使用$row[‘dateposted’],显示的是:
PHP_SQL_数据库读取的“日期”处理

通过函数date()和strtotime()处理后的源代码:

echo"In .$row['cat_id']."'>".$row['cat']." - Posted on ".date("D jS F Y g.iA",strtotime($row['dateposted']))."";

效果截图:
PHP_SQL_数据库读取的“日期”处理

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('
  • ').text(i)); }; $numbering.fadeIn(1700); }); });

    以上就介绍了PHP_SQL_数据库读取的“日期”处理,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

  • 人气教程排行