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 8248061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:04:14+00:00 2026-06-07T23:04:14+00:00

I am new to PHP and I am stuck with this problem. $mimes =

  • 0

I am new to PHP and I am stuck with this problem.

$mimes = array('application/vnd.ms-excel','text/plain','text/csv','text/tsv');
if (((in_array($_FILES['uploadedfile']['type'],$mimes)))
    && ($_FILES["uploadedfile"]["size"] > 0))
{
    $filename = $_SESSION['username'].$_FILES["uploadedfile"]["name"];
    move_uploaded_file($_FILES["uploadedfile"]["tmp_name"],"./uploads/".$filename);

    echo "Stored in: " . "./uploads/" .$filename;
    echo "<br />\n";
    echo 'Daylight hours will be calculated for this latitude : '.$_POST['latCSV'];
    echo "<br>";
    //print out uploaded file.csv
    echo "<table BORDER=1>\n\n";
    echo "  <tr><th>AvgCrown</th><th>MinCrown</th><th>MaxCrown</th><th>dateLogged</th><th>DaylightHours</th></tr>";
    echo "<tbody id='tblBdyLoggedData'>";
    $f = fopen("./uploads/" .$filename, "r");
    $i=0;   //just a counter
    while (($line = fgetcsv($f)) !== false) {
        echo "<tr>";
        foreach ($line as $cell) {
            // Save the value before you output
            $lastColValue = htmlspecialchars($cell);
            //unset($lastColValue[3]);
            echo "<td>" . $lastColValue . "</td>";

        }
        //checking if date is valid
        checkDateString($lastColValue);

        // If you want to store all log dates in an array:
        $logDates[] = $lastColValue;                            
        $firstlogDate = $logDates[$i];
        echo "<td>" . checkDateString($lastColValue) . "</td>";
        //call function using firstlogDate for every row
        echo "<td>" . calcDaylight($firstlogDate,$_POST["latCSV"]) . "            </td>";
        echo "</tr>\n";
        $i = $i+1;
    }
    fclose($f);
    echo "</tbody></table></body></html>";
}

I would like to get print only the first 3 columns of the CSV file upon file upload as the two other will be calculated using respective functions. Datelogged will be taken from the csv and reformated properly and daylight Hours is also calculated from datelogged.

  • 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-07T23:04:15+00:00Added an answer on June 7, 2026 at 11:04 pm

    May this code will help you

    ?php
    echo "<html><body><table>\n\n";
    $f = fopen("so-csv.csv", "r");
    while (($line = fgetcsv($f)) !== false) {
            $count=0;
            echo "<tr>";
            foreach ($line as $cell ) 
            {
                if($count<3)
                {    
                    echo "<td>" . htmlspecialchars($cell) . "</td>";
                    $count++;
                }
            }
            echo "<tr>\n";
    }
    fclose($f);
    echo "\n</table></body></html>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to Php OOP and am getting stuck on one particular problem.
I'm rather new to PHP and I am kind of stuck here writing this
I am new to php and trying to write a login function. Bit stuck
New to PHP and MySQL, have heard amazing things about this website from Leo
Rather new to php, so sorry if this seems stupid. I'm really copying a
I have been stuck with this problem for a while now, and I just
Client: <?php $gmclient= new GearmanClient(); $gmclient->addServer(); $gmclient->doBackground(reverse, this is a test); echo done!\n; Worker:
Hello everyone I am completely stuck with this problem. I want add the name
I'm working on a project and I'm stuck with this problem: I have a
I am new into Facebook application development and also newbie about JavaScript and PHP

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.