I am trying to build a query that will display the Amount of people that signed up in a certain month.
I am adding the date_time to the database at the time someone signs up for a course. I want to display the months and total sign-ups for the month. I code like once every two years so I tend to forget some of this stuff. (Ex: February: 23 people signed up)
If you have any thoughts as to what I can look up and learn for this it would be helpful, Thanks!
if ($result = $db->query("SELECT reg_date, COUNT(reg_date) FROM micro_applicants GROUP BY ('%m')")) {
// So the result returned true, let's loop and print out each city.
// The number of rows returned is assigned to the property "num_rows" in the mysql_result class
echo 'Date: '.$result->num_rows.' .
';
// The "fetch_object()" method is the equivalent of the old mysql_fetch_object() function. It allows access to the returned rows within the resouce object ($result in this case).
while ($row = $result->fetch_object()) {
echo '<br /> '.$row->COUNT(reg_date) . $row->COUNT('%m') . "<br />";
}
} else {
// Notice below that the errors are still contained within the mysqli class. This means that each result will affect a single "error" property. In otherwords, if your result fails, the error returned from MySQL is assigned to the property "error".
// This means the query failed
echo $db->error;
} // end else
$db->close();