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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -