How to count rows by date using MySQL and PHP

后端 未结 2 1396
既然无缘
既然无缘 2021-01-29 05:30

Well, I am developing Vote system where, i am selecting data from database using following code:

// Select info about vote
        $select_information = mysql_qu         


        
相关标签:
2条回答
  • 2021-01-29 06:02

    You forgot a comma between the fields in your select statement.

    Please change

    DATE_FORMAT(STR_TO_DATE('$dbdate', '%d/%m/%Y' ), '%d/%m/%Y') as Date COUNT(`ID`)
    

    to

    DATE_FORMAT(STR_TO_DATE('$dbdate', '%d/%m/%Y' ), '%d/%m/%Y') as Date, COUNT(`ID`)
    

    You should also change $today_voting[0]; to $today_voting[1]; because the voting count is the second column you are selecting. The first column ($today_voting[0]) contains the formatted date.

    0 讨论(0)
  • 2021-01-29 06:26

    Put comma between Date & COUNT(ID)

    $today_voting_query = "SELECT 
    DATE_FORMAT(STR_TO_DATE('$dbdate', '%d/%m/%Y' ), '%d/%m/%Y') as Date, 
    COUNT(ID) AS countID FROM `voteslist` WHERE `VoteID` = '$VoteID' AND `Date` = '$result_date';";
    
    0 讨论(0)
提交回复
热议问题