Can't get SQL query results I used a PHP code to show results of this query:

SELECT COUNT(*) FROM mytable


I want to get the number of rows in a specific table. This query works fine in phpMyAdmin, but it doesn't work when I place it in a template file.

I mean it doesn't return the number of rows.

Do you have any idea?
A template file should never contain code that executes a query; that should be done in a preprocess function, eventually. 

The code to get the number of rows in a table is similar to the following one.

$count = db_result(db_query("SELECT COUNT(*) FROM {mytable}"));


The table name should always be put between curly brackets, which will be replaced with the prefix currently set for database tables.