Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8144733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:27:45+00:00 2026-06-06T13:27:45+00:00

I am currently stuck at this problem right now where I don’t seem to

  • 0

I am currently stuck at this problem right now where I don’t seem to have any idea how to implement this. I have this table which is populated from a csv file in php and I want to get the data logged in order to calculate the daylight hours.

How can I get the data from the td “dateLogged”, I did that in jquery before using children but I do not seem to be able to do that in php

//print out uploaded file.csv
            echo "<html><body><table BORDER=1>\n\n";
            echo "  <tr><th>AvgCrown</th><th>MinCrown</th><th>MaxCrown</th><th>dateLogged</th><th>DaylightHours</th></tr>";
            $f = fopen("./uploads/" . $_FILES["uploadedfile"]["name"], "r");

        while (($line = fgetcsv($f)) !== false) {
                echo "<tr>";
                foreach ($line as $cell) {
                        echo "<td>" . htmlspecialchars($cell) . "</td>";
                }
                echo "<td>" . calcDaylight() . "</td>";

                echo "<tr>\n"; 


        }
        fclose($f);
        echo "\n</table></body></html>";

Here is a sample how the table looks like

Here is a sample how the table looks like
Any help will be most welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:27:46+00:00Added an answer on June 6, 2026 at 1:27 pm

    There’s no need to parse the HTML if you can just grab the data while you’re generating it.
    Something like this should be all you need:

    while (($line = fgetcsv($f)) !== false) {
        echo "<tr>";
        foreach ($line as $cell) {
            // Save the value before you output
            $lastColValue = htmlspecialchars($cell);
            echo "<td>" . $lastColValue . "</td>";
        }
        // If you want to store all log dates in an array:
        $logDates[] = $lastColValue;
        // Or if you want to do something with that value in calcDaylight:
        echo "<td>" . calcDaylight( $lastColValue ) . "</td>";
        echo "<tr>\n"; 
    }
    fclose($f);
    

    Incidentally, if you do find you need to parse the HTML and are only familiar with jQuery, this library may strike your fancy:

    http://code.google.com/p/phpquery/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been stuck with this problem for a while now, and I just
I'm currently stuck on this problem. I've hooked into the method_missing function in a
I have been looking for a solution to this problem for a while now
I have this problem; I'm currently doing some modification on a web application that
I have a css-problem I really don't seem to understand :) I have been
Been stuck on this for ages. Currently learning Django and done some bits on
My app, tommienutest is currently stuck in Awaiting Recurring Charge Cancellation-limbo. Is there any
I am currently working on a problem that I have an inelegant solution for.
I'm stuck with this for several hours now and cycled through a wealth of
I've searched and searched, and it seems I'm stuck on this problem. Somehow I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.