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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:24:34+00:00 2026-06-15T09:24:34+00:00

I want to use a csv file to update the mysql scv table. how

  • 0

I want to use a csv file to update the mysql scv table. how to code ? I have no experiece doing this job.

<p>please select a scv file to upload</p>
<form action="index.php" method="post">
    <input type="file" name="scv"  />
    <input type="submit" value="submit" />
</form>
<?php 
    mysql_connect('localhost','root','admin');
    mysql_select_db('linjuming');
    // how to upload a scv file and insert or update the "csv" table?

?>

enter image description here

  • 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-15T09:24:35+00:00Added an answer on June 15, 2026 at 9:24 am

    Your upload file:

    <form action="upload_target.php" method="post" enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file"><br>
    <input type="submit" name="submit" value="Submit">
    </form>
    

    Your upload_target.php

    $ext = pathinfo($_FILES[‘file’][‘name’], PATHINFO_EXTENSION);

    if ($ext == "csv" && $_FILES["file"]["error"] == 0)
    {
        $target = "upload/" . $_FILES["file"]["name"];
        move_uploaded_file($_FILES["file"]["tmp_name"], $target);
    
        if (($handle = fopen($target, "r")) !== FALSE) 
        {
            while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) 
            {
                print_r($data);
            }
    
            fclose($handle);
        }
    }
    

    Very basic and with very few checks / validations. The print_r($data) contains one line of your csv that you can now insert in your database.

    However, I would recommend using PDO or MySQLi for that task, since the mysql functions of PHP will be deprecated in the future.

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

Sidebar

Related Questions

I have a transaction log file in CSV format that I want use to
I want to be able to use Python to open a .csv file like
I want all CSV files in a directory, so I use glob('my/dir/*.CSV') This however
I want use this 1 for using Bar code or QR code scanner. I
In my application i have to read data from a CSV file. I want
I want to load a CSV file that looks like this: Acct. No.,1-15 Days,16-30
I want to export the exist data into csv file. I try to use
Basically my problem is this: I have a CSV excel file with info on
i am sending a csv file as a header and i want to use
I am trying to read a CSV file using PHP. I want to use

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.