如何使用MySQL和PHP按日期计算行数

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

// Select info about vote
        $select_information = mysql_query("SELECT * FROM `Vote` WHERE `VoteID` = '$VoteID';");
            $take = mysql_fetch_array($select_information);
            $createdBy = $take["Username"];
            $InstaCredit = $take["InstaCredit"];
            $activeVote = $take["Available"];
            $select_last_vote = mysql_query("SELECT `Date` FROM `voteslist` WHERE `IP` = '$ip' AND `VoteID` = '$VoteID' order by `Date` DESC LIMIT 1;");
            $select_last_vote = mysql_fetch_array($select_last_vote);
            $dbdate = $select_last_vote["Date"];

## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## 
// Here i am select date. retrieve just the date part
            $takeResult = mysql_query("SELECT DATE_FORMAT(STR_TO_DATE('$dbdate', '%d/%m/%Y' ), '%d/%m/%Y') as Date ;");
            $Result_date = mysql_fetch_array($takeResult);
            $result_date = $Result_date["Date"];
            $today = date("d/m/Y");
            $thanks_to = $createdBy;

// here my problem. I want count all votes from today.
            $today_voting_query = "SELECT DATE_FORMAT(STR_TO_DATE('$dbdate', '%d/%m/%Y' ), '%d/%m/%Y') as Date COUNT(`ID`) FROM `voteslist` WHERE `VoteID` = '$VoteID' AND `Date` = '$result_date';";
            $today_voting = mysql_fetch_array($today_voting_query);
            $today_voting = $today_voting[0];
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##

            //now compare your dates
            if($result_date == $today)
            {
                echo "<span class='thanks-for-voting voted'>
                error <strong>{$thanks_to}</strong>
                </span><br />
                <span class='note-vote voted'>You can vote one time in 24 hours</span>";
            }
            else {
                echo "
                <span class='thanks-for-voting'>
                Thanks for vote to <strong>{$thanks_to}</strong>!
                </span>
                ";
            }
    ?>
        <div class="statics">
        <span id="static-title">Statics <?php echo $thanks_to; ?></span><hr />
        <span id="static-q">Today votes:</span> <span id="static-a"><?php echo $today_voting; ?></span><br />
        <span id="static-q">Votes:</span> <span id="static-a">19</span><br />
        </div>

I need to count and print the value of Today's votes by the following variable: $today_voting

see: Select date from my db without seconds using PHP MySql

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.

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';";