我一直給自己一個基本的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