我有以下查询,现在如何在<p>
标记
SELECT COUNT( question_status) AS active_questions
FROM questions_table
WHERE question_status = "Active"
答案 0 :(得分:1)
http://nl3.php.net/manual/en/function.mysql-query.php
http://nl3.php.net/manual/en/mysqli.query.php
上面的链接都为您提供了足够的信息来显示输出。别忘了用&lt; p&gt;包围它。标签
答案 1 :(得分:1)
回到完成基础:
<?php
$connection = mysql_connect($DB_hostname, $DB_username, $DB_password) or die(mysql_error());
mysql_select_db($DB_name, $connection);
$query = mysql_query("
SELECT COUNT(question_status) AS active_questions
FROM questions_table
WHERE question_status = "Active"
", $connection) or die(mysql_error());
echo '<p>';
while ($myrow = mysql_fetch_array($query))
{
echo $myrow['active_questions'];
}
echo '</p>';
这绝不是严格的,它不使用任何外部(或有价值的库,如PDO),但应该让您了解如何简单地实现和呈现结果集。
您应该在mysqli / PDO和其他人上探索/阅读更多功能/实用程序。