Upload CSV and Insert Data into Mysql Using PHP

Sdílet
Vložit
  • čas přidán 17. 04. 2016
  • You can find how import data from csv file and insert into mysql table in php. Here I show you user first upload csv file and with help of php code we can get csv file data and make mysql insert query and insert that data to mysql table. Source Code - www.webslesson.info/2016/04/up...

Komentáře • 75

  • @Sami-sg5os
    @Sami-sg5os Před 4 lety +7

    Thank you !
    For those who have the error "Notice: Undefined offset: 1", you can replace the line of code "while($data = fgetcsv($handle))" with this one "while($data = fgetcsv($handle,1000,";"))". You must specify the separator.

  • @kobimontague2101
    @kobimontague2101 Před 8 lety +1

    apart from the computer talk..this really helped me upload a lot of data to the mysql data base.
    Thanks for the code...
    Kobi

  • @agehjeremiah
    @agehjeremiah Před 5 lety

    Awesome Tutorial. Thanks Webslesson!!!

  • @orpee4486
    @orpee4486 Před 6 lety

    Thank you so much. You're so resourceful.

  • @danielchung0228
    @danielchung0228 Před 4 lety +2

    it doesn't work for me. Nothing happens.
    very frustrating because I did everything what you did and it doesn't work for me.

  • @VFRodriguez
    @VFRodriguez Před 4 lety

    Good example. Easy to learn. Thanks.

  • @user-fw2ur9jy3z
    @user-fw2ur9jy3z Před 4 lety +3

    Apart from saying "friends" 1Milloin times
    That wae very helpful ...
    Friend 😁♥

    • @dbs253
      @dbs253 Před 4 lety

      Exactly what I was going to say too!

  • @mutalemulenga8708
    @mutalemulenga8708 Před 3 lety

    Wow. this is awesome. I never wanted to use third parties library and here is pure php system.

  • @miteshnile7350
    @miteshnile7350 Před 4 lety

    Thank you very clear explanation!

  • @jsfahmi
    @jsfahmi Před 4 lety +1

    thank you friends

  • @CarlosMoreno-vw4ir
    @CarlosMoreno-vw4ir Před 4 lety

    Thanks a lot, you are a hero !

  • @pallavigupta321
    @pallavigupta321 Před 6 lety

    great video it worked for me thanks

  • @geethavadupu1760
    @geethavadupu1760 Před 4 lety

    thnks sir its working..helpful to me

  • @ekanshbihal2850
    @ekanshbihal2850 Před 5 lety +1

    Hello sir, thanks for code. Sir, i have two queries. When i upload CSV file using this code, CSV heading at the top of csv are also upload in database. Tell me which condition is used for this and also tell me how i validate csv in uploded time using php that data should not repeated again.

  • @user-dt9uv4ww7v
    @user-dt9uv4ww7v Před 8 měsíci

    Thank you very much sir

  • @AlinafeNthondowaCode-Zero

    Thanks it worked

  • @umabm502
    @umabm502 Před 7 lety

    It is getting inserted but not with actual value... help me out with this

  • @moussaabbouzid579
    @moussaabbouzid579 Před 5 lety

    Thanks u so much bro ❤️❤️❤️

  • @hyasinti
    @hyasinti Před 4 lety +1

    Thanks is very useful, but is there any way that I can convert excel file to csv in php without using plagins

  • @codingbladeit8255
    @codingbladeit8255 Před 5 lety

    Thank you so much

  • @--INDIAN--TRADER
    @--INDIAN--TRADER Před 7 lety

    very nice clear and precise thanks a ton

  • @emmanuelepiscope4853
    @emmanuelepiscope4853 Před 3 lety

    thank you

  • @pallavi7116
    @pallavi7116 Před 5 lety

    Thanks 😊❤️

  • @parthpd3781
    @parthpd3781 Před 4 lety

    csv file add images how can get that image save folded and database add in php

  • @dhruvchauhan5581
    @dhruvchauhan5581 Před 4 lety +2

    The line :
    ($_FILES['file']['name'])
    Is giving an error as : Undefined index: file
    How to solve this issue?

  • @balikahinge2226
    @balikahinge2226 Před 4 lety

    can u store image using csv

  • @parichartkittikhun4666

    Thank you so much :)

  • @samikhaneth
    @samikhaneth Před 3 lety

    if entry exit then wont be uplaod again ? how to put code in this section and which code?

  • @AhmedAli-ky6jt
    @AhmedAli-ky6jt Před 5 lety

    Is this will be work on live server ??

  • @yashrojha
    @yashrojha Před 3 lety

    Thanks

  • @niceboyyou
    @niceboyyou Před 7 lety +1

    This is fantastic and helpful
    How we can add the data by escaping the first row

    • @ninthcrusade4871
      @ninthcrusade4871 Před 4 lety

      Use a variable counter. If the counter is greater that '0' then insert the data.
      $Flag = 0;
      while($data = fgetcsv(($handle))
      {
      if($Flag != 0)
      {
      // Execute the insert inside of this if statement
      }
      if($Flag == 0) $Flag = 1;
      }

  • @nigochen6665
    @nigochen6665 Před 6 lety

    Thanks :)

  • @ariefunited07
    @ariefunited07 Před 6 lety +2

    i get this notice but i can"t solve the problem
    Notice: Undefined offset: 1 in C:\xampp\htdocs\PhpProject1\index.php on line 14
    help me to figure it out
    thanks

    • @moussaabbouzid579
      @moussaabbouzid579 Před 5 lety

      i have the same problem bro can u halp me plz :/

    • @pranotipatil7070
      @pranotipatil7070 Před 4 lety

      I'm facing the same issue ....now its fixed use the correct csv file format.

    • @Sami-sg5os
      @Sami-sg5os Před 4 lety

      @@pranotipatil7070 you can replace the line of code "while($data = fgetcsv($handle))" with this one "while($data = fgetcsv($handle,1000,";"))". You must specify the separator.

  • @shovonrahmanshuvo
    @shovonrahmanshuvo Před 7 lety +1

    Great one.made my life easier... :D (Y)

  • @robertbobila4682
    @robertbobila4682 Před 6 lety

    Good day sir.
    Is this compatible for php 5?
    Or 7 only?
    Thanks.

    • @webslesson
      @webslesson  Před 6 lety

      Yes, it is compatible with both PHP 5 and 7.

  • @gokuldasvs2205
    @gokuldasvs2205 Před 7 lety

    useful

  • @obeddordor
    @obeddordor Před 7 lety

    thx friends!

  • @gz3442
    @gz3442 Před 8 lety

    can i do that with file type is xlsx ?

  • @tordbjornalbertsen2901

    Okay i hope they rede and fixit

  • @elysiumstudios
    @elysiumstudios Před 6 lety

    Thank you

  • @snatandharma6
    @snatandharma6 Před 4 lety

    Import nhi ho rha hai item1 and...item2 uninitialized bta rha Ha i

  • @amnaiqbal3080
    @amnaiqbal3080 Před 4 lety

    after choosing the file when we upload it, it returns no file chosen

  • @tordbjornalbertsen2901

    Notice: Undefined offset: 1 in /Applications/MAMP/htdocs/finans_dk.dk/upload_csv/index.php on line 14

  • @tordbjornalbertsen2901

    again it is a problem in item2 that my mysqli will not accept, there is a solution :-((

  • @jihaddarmawan7985
    @jihaddarmawan7985 Před 5 lety

    Not work

  • @sagarkaushal5228
    @sagarkaushal5228 Před 6 lety

    Sir to me again and again no file choosen is shown please solve my problem

    • @bulbulrani9307
      @bulbulrani9307 Před 6 lety

      have you find any solution?

    • @orpee4486
      @orpee4486 Před 6 lety

      Save your excel file as CSV (Comma Delimited). Choose "CSV (Comma Delimited)" in "Save as type"

  • @zahidqureshi9523
    @zahidqureshi9523 Před 6 lety

    how can use 77mb file

    • @webslesson
      @webslesson  Před 6 lety

      Have you tried Zahid Queshi to upload this type of heavy file, for export this type of file you have to set server property.

    • @zahidqureshi9523
      @zahidqureshi9523 Před 6 lety

      my csv file is 77mb and not import this file

    • @zahidqureshi9523
      @zahidqureshi9523 Před 6 lety

      how import this file

  • @attotadinesh356
    @attotadinesh356 Před 7 lety

    undefined index file : error -- i'm getting
    Is there any solution for that error to get clear

  • @moussaabbouzid579
    @moussaabbouzid579 Před 5 lety

    Thanks u so much bro ❤️❤️❤️