我一直给自己一个基本的PHP进修课程,而不使用模板引擎(尽管我最近学到了一些Smarty和Twig,我觉得我应该继续练习基本的PHP),并且这是我的显示车辆的清单基本页面,当他们注册:Strtotime在MySQL查询[基本PHP页面]
<?php
// Connects to your Database
mysql_connect("localhost", "testing", "testingpass") or die(mysql_error());
mysql_select_db("cars1") or die(mysql_error());
$data = mysql_query("SELECT * FROM autos")
or die(mysql_error());
echo "<table border cellpadding=3>";
while($info = mysql_fetch_array($data))
{
"<tr>";
//echo "<td>"date("d M Y",strtotime($info['registered']));"</td> ";
echo "<td><tr>".$info['make'] ." ".$info['model'] ."</td><tr> ";
}
echo "</table>";
?>
它的工作原理,如果日期时间被注释掉,但如果它注释掉的页面显示为空白 - 我用甲基苯丙胺作为我的web服务器,最新的PHP。
对于一个简单的页面,这个效果很好,但我应该如何格式化这个日期? (我使用教程http://erikastokes.com/mysql-help/display-mysql-dates-in-other-formats.php来试试这个)。
我应该做些什么修改来解决这个问题的日期和时间,否则它很适合作为基本的MySQL php查询。
加上'使用error_reporting(E_ALL)'顶端。你的错误默认是关闭的。 – castis 2013-03-18 17:29:20
学习如何使用'echo',阅读文档 – 2013-03-18 17:30:02
做一个var_dump($ info));你会看到什么是错的 – Ibu 2013-03-18 17:30:42