logo
down
shadow

Display dates in a HTML table for each month with PHP


Display dates in a HTML table for each month with PHP

By : jess
Date : November 22 2020, 09:00 AM
I think the issue was by ths following , I'm trying to display dates in a HTML table. I want to display each month, but I failed when the dates go over a month for example: 2015-30-11 to 2015-01-12 , Revise your inner loop like this:
code :
 for($l=0;$l<$table;$l++){


    $mark = false;
    for($y=0; $y<$count_absences; $y++){
        $start =  $absences[$y]['start'];
        $end = $absences[$y]['end'];
        $dStart = new DateTime($start);
        $dEnd  = new DateTime($end);
        $dDiff = $dStart->diff($dEnd);
        $diff = $dDiff->days + 1;     

        $start_day = date('d', strtotime($start)) - 1;
        $start_month = date('m', strtotime($start));

        $lString = $year.'-'.$month.'-'.($l+1);
        $lDate = new DateTime($lString);
        if($lDate>=$dStart && $lDate<=$dEnd){
            $mark = true;
            break;
        }
    }
   if($mark){
        echo "<td>X</td>";
    } else {
         echo "<td></td>";
    }



unset($employee);
}


Share : facebook icon twitter icon
How to display dates in two html tables side by side according to month?

How to display dates in two html tables side by side according to month?


By : user3107467
Date : March 29 2020, 07:55 AM
Hope this helps Instead of having a counter and creating a new table when it hits 15, you want to have a variable that stores the month number of the last row rendered, and check if the month number of the next row to be rendered matches. If it doesn't match, generate a new table.
The following code is produces the results you want. I've tested it with a database table with identical structure (table named "test_employees").
code :
<!DOCTYPE html>
<html>
<head>
<title>table test</title>
</head>
<body>

<?php
    $name=$_SESSION['sess_username'];
    $dateofattendance=$_SESSION['sess_date'];
    $time="00-00-00";
    $status="absent";
    $counter=0;
    $conn = new mysqli('localhost', '', '', 'test_employees');
    $sql="SELECT dateofattendance,timeofattendance, status,timeofdeparture FROM attendance Where emp='$name' ORDER BY dateofattendance ASC ";
    $result = $conn->query($sql);

    if ($result->num_rows > 0)         
    {
        echo "<table border='1'>";
        echo "<thead>";
        echo "<tr>";
        echo "<th>Date</th>";
        echo "<th>IN</th>";
        echo "<th>OUT</th>";
        echo "<th>Status</th>";
        echo "</tr>";
        echo "</thead>";
        echo "<tbody>";

        $first_iteration = 1;
        $row = $result->fetch_array(MYSQLI_ASSOC);
        $last_month_num = split('-', $row["dateofattendance"])[1];

        while($row = $result->fetch_assoc())
        {
            $current_month_num = split('-', $row["dateofattendance"])[1];

            if ($first_iteration == 1) { // do nothing the first time around
                $first_iteration = 0;
            }
            else if ($current_month_num == $last_month_num) { // only close row in current table
                echo "</tr>";
            }
            else { // close table and start new table
                echo "</tr>";
                echo "</table>";
                echo "<table border='1'>";
                echo "<thead>";
                echo "<tr>";
                echo "<th>Date</th>";
                echo "<th>IN</th>";
                echo "<th>OUT</th>";
                echo "<th>Status</th>";
                echo "</tr>";
                echo "</thead>";
                echo "<tbody>";
            }

            echo "<tr>" . "\n";

            echo "<td>" . "\n" . $row["name"] . $row["dateofattendance"] . "\n" . "</td>" . "\n";
            echo "<td>" . "\n" . $row["timeofattendance"] . "\n" . "</td>" . "\n";
            echo "<td>" . "\n" . $row["timeofdeparture"] . "\n" . "</td>" . "\n";

            if($row["status"]=='present')
            {
                echo "<td><span class='label label-success'>". $row["status"]."</span></td>";
            }
            else
            {
                echo "<td><span class='label label-danger'>". $row["status"]."</span></td>";
            }

            $counter++;

            $last_month_num = split('-', $row["dateofattendance"])[1];
        }

        echo "</tr>";
        echo "</table>";
    }


    $conn->close();
?>

</body>
</html>
How to display data for a certain period of time (day / week / month) from Mysql table in html table (php)

How to display data for a certain period of time (day / week / month) from Mysql table in html table (php)


By : maryj.blige
Date : March 29 2020, 07:55 AM
I wish this helpful for you if i got it true you want to show data that added for specific date/time or between date/time ranges. you should use mysql query to get data that for example last day added. you should change query:
code :
$qr_result = mysql_query("select * from " . $db_table_to_show)  
SELECT * FROM [TableName] WHERE `AddedDate` BETWEEN "2012-03-15" AND "2012-03-31";
How to display the entire month dates as a header for the particular month selected

How to display the entire month dates as a header for the particular month selected


By : yowngb
Date : March 29 2020, 07:55 AM
I wish this help you I'm new to Angularjs, i want to display the entire month dates as a header, when im selected from the date picker for that particular month dates should be display like that only for other month based on the selection, to check the attendance of the employee , You should try this:
create month HTML which will be:
code :
<select ng-model="calculate.months" ng-change="monthCalculate(calculate.months)">
            <option ng-repeat="x in monthsValue" value="{{x.value}}">{{x.name}}</option>
        </select>
 $scope.monthsValue = [
            {name: "January", value: "1"},
            {name: "February", value: "2"},
            {name: "march", value: "3"}
        ];
    <div ng-model="totalDays">
        <div ng-repeat="i in range(totalDays) track by $index">
            <span> {{$index + 1}} </span>
        </div>
    </div>
$scope.monthCalculate = function (months) {
            getMonthDays = daysInMonth(months, 2016);
            $scope.totalDays = getMonthDays;
        };

        function daysInMonth(month, year) {
            return new Date(year, month, 0).getDate();
        }

        $scope.range = function (n) {
            return new Array(n);
        };
Passing dates to the stored procedure and get details in return to display in html table

Passing dates to the stored procedure and get details in return to display in html table


By : azhar
Date : March 29 2020, 07:55 AM
To fix the issue you can do Don't use startdate and endate in your url because / characters are not encoded
code :
var url = webApiUrl + 'api/ProjectDetails/GetTableSubmittedDetails/'
How to display html month tag input already saved in sql in format Month, year?

How to display html month tag input already saved in sql in format Month, year?


By : imeda dolidze
Date : March 29 2020, 07:55 AM
should help you out I have used html input month tag to take a calender entry as was required by client, it was saved as text in sqldatabase table, its in format 2019-03 where as I need it in March-2019 format.. , This is could give you the desired output.
code :
<?php 
print date('F-Y', strtotime($string)); // $string would be database column name
?> 
Related Posts Related Posts :
  • Generating all 6 character alphanumeric combinations (upper and lower case)
  • PHP: Swap placeholders in string variable for corresponding defined variable values
  • HTTP request failed! with file get contents
  • How can I manipulate include_once string?
  • Database table not created after running plugin:refresh
  • Sphinx Get Word in Result through PHP API
  • Sending xml via soapclient in PHP
  • PHP class extension - skipping the middle class by calling the parent of the parent
  • Save data from contentEditable div with mysqli
  • Generating a PDF with sequential order images FPDF
  • How to make a request with PHPLeague oAuth2 client?
  • MySQL count rows with two duplicate column values
  • How to send a curl request with pem certificate via PHP?
  • Request error when processing form in controller
  • Can't save xml file content in mysql with fopen/fwrite/fclose (php)
  • Read only Title from a page?
  • PHP - make echo permanent and visible to all viewers
  • composer fails on server with redmine installed
  • Using foreach With Variables on Smarty
  • How do you specify single print blocks when looping through a 'for' loop?
  • PHP: $_FILES returns empty
  • Symfony2 associative array in entity
  • How do I log every output from a PHP script from the command line?
  • How to implement this json feed into a database structure?
  • Codeigniter, windows, xampp, how to use htaccess to get rid of trailing slash?
  • How to disable Navbar and footer in Yii2 other layouts
  • Json not encode my Special Character
  • echo if POST length is low
  • Warning: require_once error
  • What is this code meaning...?
  • Send to /dev/null a PHP function "echo" output
  • How to store post details and timestamp in database?
  • php mysql - search a row and concatenate values of every columns to variable string
  • Write a program to get N number of positive non-zero integers, so that the sum and product of these numbers are equal
  • Running two multi line queries in PHP
  • PHP/ASP Trouble understanding
  • Strict standards notices View/Layout class
  • how to have backwards reference on PHP's regex?
  • Uncaught exception 'RuntimeException' with message 'Unable to load ZF2. Run `php composer.phar install` or define a ZF2_
  • phpDocumentor: DocBlock with @var tags duplicates descriptions
  • how to push an object to an array within an object with PHP
  • Undefined offset error in for loop
  • mysql query logic for fetching data from 3 related tables on certain condition
  • Saving blob video with php
  • SpeckPaypal ZF2 How to edit the CURRENCY CODE?
  • How to filter associated HABTM data with FriendsOfCake Search for CakePHP 3
  • Check ALL $_POST lengths
  • PHP - Recursively set each array element's key to the value of a child element when given the childs key name
  • How to disable the user from entering wrong passwords
  • SilverStripe Custom Email Form - jQuery.ajax not passing variables to server
  • Regular expression to extract Facebook URL's inc vanity
  • Show Calculated Field on SuiteCRM Dashlet
  • Class 'NumberFormatter' not found error in simple PHP program
  • Is it necessary to set values to a variable two times?
  • Scan Barcode - Save Code in SQL Database
  • Fetch MySQLi with custom database (aka, column names for array keys)
  • Symfony2 PagerFantaBundle
  • Wordpress: Restrict file uploads by MIME type
  • Find key in array in a foreach
  • pdo select query wont works with string of letters
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co