PHP mySQL votes this month? -
so have voting system. everytime votes, adds new row column called 'votes' details + date, time.
in admin panel, want add feature how many votes have gained month.
how can this?
maybe select rows date not lower curdate() + 30 days, , if yes, delete them ad count how many rows have?
public function votesthismonth() { $this->query = $this->pdo->prepare("select * votes date<date_sub(curdate(), interval 30 day)"); $result = $this->query->execute(); return $result; }
no need delete anything. mysql can handle lot of data quite easily. @ job have half billion rows in tables.
in query below change year , month current month want query.
select count(*) num_votes tablename year(datecol) = year(current_date) , month(datecol) = month(current_date)
Comments
Post a Comment