I create this code to upload CSV in database in packets of 100.

Overview

PHP-CSV-Upload

I create this code to upload CSV in the database in packets of 100 elements in one for loop.

Hi, This is Anmol Singh.

To reach our Goal, First I Capture CSV data after that explode into lines. Then, put that exploded lines as an array in an array by the index of row.

After that, Capture the number of times the loop took. Then, Divide it by 100 and Change it in int and store it in $whileRun. then, Run the While loop $whileRun Times so that we cove all data.

After that, We find out how many times our For loop have Run by simply, First How many Entries left After All While loop Multiply by How many times For loop gonna Run in Per While Loop, In My case, it is 100. So $runAfter = $arraySize - $whileRun * 100; Second, I find out How many Entries have to run in Forloof that is, $run = $arraySize - $runAfter;

Now, All set up.

First, I initialize $size which monitors How many times While Loop Run. And then, I initialize $ifSize which monitor How many times For Loop Run.

After that, I run While Loop with a condition where $size has to be smaller or equal to $whileRun. Start MySQL connection. Checking Condition $ifSize is smaller or equal to $run. Running for loop 100 times. Monitoring Entries by adding 1 to $i.

if the $ifSize becomes greater than $run then compiler comes to else condition, Where for loop run $runAfter times.

And I get my goal complete.

This is simple code to upload CSV data into Mysql Database, You can use this code as Core and Create a Plugin or Apps where one can upload the CSV in Plugin or Apps and it will upload as New Entries Or Create a condition that gives the User to Select Between New Entries or Update Old Ones. In Any Case, if you Feel like This Code Can Help You. Please Let Me Know.

You might also like...
Improve default Magento 2 Import / Export features - cron jobs, CSV , XML , JSON , Excel
Improve default Magento 2 Import / Export features - cron jobs, CSV , XML , JSON , Excel

Improve default Magento 2 Import / Export features - cron jobs, CSV , XML , JSON , Excel , mapping of any format, Google Sheet, data and price modification, improved speed and a lot more!

Parse your humble choice / monthly data and compile a CSV list for better overview

humbleparser Parse your humble choice / monthly data and compile a CSV list for better overview Requirements PHP CLI (= 7.4)) php-curl Note I have ne

Provide CSV, JSON, XML and YAML files as an Import Source for the Icinga Director and optionally ship hand-crafted additional Icinga2 config files
Provide CSV, JSON, XML and YAML files as an Import Source for the Icinga Director and optionally ship hand-crafted additional Icinga2 config files

Icinga Web 2 Fileshipper module The main purpose of this module is to extend Icinga Director using some of it's exported hooks. Based on them it offer

Laravel Larex lets you translate your whole Laravel application with a single CSV file.
Laravel Larex lets you translate your whole Laravel application with a single CSV file.

Laravel Larex Laravel Larex lets you translate your whole Laravel application with a single CSV file. You can import translation entries from lang fol

World countries - available in multiple languages, in CSV, JSON, PHP, SQL and XML formats

Constantly updated lists of world countries and their associated alpha-2, alpha-3 and numeric country codes as defined by the ISO 3166 standard, available in CSV, JSON , PHP, SQL and XML formats, in multiple languages and with national flags included; also available are the ISO 3166-2 codes of provinces/ states associated with the countries

Upload attachments to content storage platform like Aliyun OSS, Tencent COS

Overview Yun storage provides a layer that mediates between a user or configured storage frontend and one or several storage backends. Note: jichangfe

Add information about PGP public keys on upload in Kirby v3
Add information about PGP public keys on upload in Kirby v3

Kirby3 GnuPG This plugin adds information about PGP public keys on upload, using gpg binary (which needs to be installed for this to work). Getting st

File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery

File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (Google App Engine, PHP, Python, Ruby on Rails, Java, etc.) that supports standard HTML form file uploads.

A dockerized PHP application containing some file upload vulnerability challenges (scenarios)

File Upload Vulnerability Scenarios (Challenges) This repository is a dockerized PHP application containing some file upload vulnerability challenges

Owner
Anmol Singh
PHP Developer
Anmol Singh
Magento commands to find translations that are present in one CSV file but not in another, and to translate CSV dicts with DeepL

Hyvä Themes - Magento translation CSV comparison command hyva-themes/magento2-i18n-csv-diff This module adds the bin/magento i18n:diff-csv and i18n:tr

Hyvä 6 Oct 26, 2022
Wake PC is a super tiny password protected webapp for linux machines that sends WOL packets, written in PHP.

Wake PC Wake PC is a super tiny password protected webapp for linux machines that sends WOL packets, written in PHP. How to set up Quick setup You can

Dániel Szabó 45 Dec 30, 2022
PocketMine-MP virion for easy handling of ScoreBoard packets

PocketMine-MP virion for easy handling of ScoreBoard packets

pocketmine virions of avas 3 Apr 9, 2022
Buy and sell crypto top 100 crypto with our fake currency. Donate to and use our referal links for discounts

PLEASE ENABLE SQLITE3 AND GD OR GD2 IN XAMPP TO RUN THE APP! (SEE HOW_TO_SETUP_XAMPP.gif) ![alt text](https://github.com/Tby23rd/Project1-Cryptosimul

Tabitha Maru 0 Dec 26, 2021
Automatically load the next page of products in Magento. Easy to install and configure, this module works 100% out of the box with vanilla Magento 1.9.x and earlier.

Automatically load the next page of products in Magento. Easy to install and configure, this module works 100% out of the box with vanilla Magento 1.9.x and earlier.

Strategery 123 Nov 20, 2021
⚡ Php snippets, random stuff, demos, functions, fast message system, agnostic and framework free - 100% compactible ;) ⚡

⚡ Php8 FPM Nginx Fast, Scripts, Pearls & Treasures ?? Want to run and test asap ? docker-compose up -d phpgit_php8;ip=$(docker-machine ip default);ech

Benjamin FONTAINE 0 Mar 20, 2022
Here is the top 100 PHP functions: it is the list of the most often used PHP native functions

Here is the top 100 PHP functions: it is the list of the most often used PHP native functions. If you are a PHP developer, you must know the Top 100 PHP Functions deeply.

Max Base 16 Dec 11, 2022
This is a small piece of code to steal firefox's cookies and upload to server (Written in VBA)

Steal-firefox-cookies-VBA-macro This is a small piece of code to steal firefox's cookies and upload to server (Written in VBA) Please note For educati

HitmanAlharbi 6 Sep 27, 2022
Magento 2 Module for parsing xlsx, xlsm and csv files from Excel

Magento 2 Spreadsheet Parser Facts Parse XLSX, XLSM and CSV Files from Excel Requirements PHP >= 7.0.* Magento >= 2.1.* Compatibility Magento >= 2.1 U

Stämpfli AG 9 Sep 24, 2020