jeudi 29 septembre 2016

PHP/MySQL - Get results from specific date, but if more results exists from one day show different

I have the following code

        foreach ($dates as $dateS) {
                        // Check if subject contains error
    $queryCheck = mysqli_query($con, "SELECT Date, Subject, Sender, Checks.Check, Checks.Status, Checks.Color, Jobs.JobAutotaskID
FROM EmailHistory
JOIN Jobs ON EmailHistory.Subject LIKE CONCAT(  '%', Jobs.JobSubjectCheck,  '%' ) 
JOIN Checks ON EmailHistory.Subject LIKE CONCAT(  '%', Checks.Check,  '%' ) 
WHERE EmailHistory.Date between '$dateS 00:00:00' AND '$dateS 23:59:59'
ORDER BY DATE ASC
"); 

    if (mysqli_num_rows($queryCheck) == 0) {

        echo "<div class=\"col-md-1\">No Backup $dateS</div>";  
    }
    else
    {
        while ($rowCheck = mysqli_fetch_array($queryCheck)) {
        if (mysqli_num_rows($queryCheck) <= 1) {
        $RowCount = mysqli_num_rows($queryCheck);
        $EmailHistoryDate = $rowCheck["Date"];
        $EmailHistorySubject = $rowCheck["Subject"];
        $EmailHistorySender = $rowCheck["Sender"];
        $ChecksCheck = $rowCheck[03];
        $ChecksStatus = $rowCheck[04];
        $ChecksColor = $rowCheck[05];

        $EmailHistorySubjectFixed = htmlspecialchars($EmailHistorySubject); 
        if  ($ChecksStatus == "OK") { echo "<div class=\"col-md-1\"><button type=\"button\" class=\"btn btn-outline btn-success\" data-toggle=\"popover\" data-placement=\"top\" data-content=\"$EmailHistoryDate - $EmailHistorySender - $EmailHistorySubjectFixed)\">OK</button></div>"; }
        if  ($ChecksStatus == "Warning") { echo " <div class=\"col-md-1\"><button type=\"button\" class=\"btn btn-outline btn-warning\" data-container=\"body\" data-toggle=\"popover\" data-placement=\"top\" data-content=\"$EmailHistoryDate - $EmailHistorySender - $EmailHistorySubjectFixed)\">Warning</button></div>"; }
        if  ($ChecksStatus == "Error") { echo "<div class=\"col-md-1\"><button type=\"button\" class=\"btn btn-outline btn-danger\" data-toggle=\"popover\" data-placement=\"top\" data-content=\"$EmailHistoryDate - $EmailHistorySender - $EmailHistorySubjectFixed)\">Error</button></div>"; }
        echo " ";
       } else { 
           // Show backups with more then 1 result
           echo "<div class=\"col-md-1\">$dateS </div>"; }

        }


    }
    }

That does the following (see image): backup view

What i also wants is that if i get a result where more then 1 job is returned(as the images shows for the date 2016-09-25), i only wants to show it one in the view(just like the other dates is), but i want to be able show all the results from that one, when i click on the OK/Warning/Error button.

Aucun commentaire:

Enregistrer un commentaire