$foot = mysql_query("SELECT count(*)
FROM tblQA
WHERE intResponseID = ''
AND cCategory = 'Football' as qcount,
(SELECT max(dPostDateTime)
FROM tblQA
WHERE intResponseID = ''
AND cCategory = 'Football') as lastq");
$football = mysql_fetch_array($foot);
echo "<td class='forum'>" . $footbll['qcount'] . "</td>";
echo "<td class='forum'>" . $footbll['lastq'] . "</td>";
这不会在我的表格中显示任何内容。我没有发布完整的 HTML 代码,我的表结构很好。
最佳答案
使用:
$foot = mysql_query("SELECT COUNT(*) AS qcount,
MAX(dPostDateTime) AS lastq
FROM tblQA
WHERE intResponseID = ''
AND cCategory = 'Football' ");
$football = mysql_fetch_array($foot);
echo "<td class='forum'>" . $football['qcount'] . "</td>";
echo "<td class='forum'>" . $football['lastq'] . "</td>";
我重写了您的查询,这一切都可以在一条语句中完成。
关于php - 我哪里错了?查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4004716/