Hello everyone,
Before I start, I have: PHP v 5.3.0, MySQL v5.1.36.
I have numbers in my database table which is structured like this:
CREATE TABLE results (
id int(11) NOT NULL auto_increment,
number int(3) NOT NULL,
type varchar(50) NOT NULL,
datetime DATETIME NOT NULL,
PRIMARY KEY (id)
);
For now I am only using numbers 0 - 5 and the numbers are ordered by number; ascending in the table...
I am trying to count the number of times each individual number was entered into the database over the last 100 entries.
So I would be able to say, over the last 100 entries, 1 was entered 20 times, 3 was entered 8 times etc..
This is the sql statement that I have:
SELECT DISTINCT COUNT(number) FROM (SELECT number FROM results WHERE type='type1' ORDER BY datetime DESC LIMIT 100)
When I try to loop through the result, I don't get an error I only get this warning:
"Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in ... "
Any help or ideas would be greatly appreciated.
Thanks.