Sep 24, 2020
Share article to
Illustration of Excel data into MySQL in one-way.
I have a task to update the thousands 'Date of Births' of Excel datas into database. To load manually with Form input will be have a long time. This is the solution for update many Records 'date' in Excel to existing table in MySQL. Date format in Excel Change Date format in Excel to format in MySQL. Columns in Excel Identify the Column 1, Column 2, ... Columns for name in MySQL Table structure. PHP Excel Reader Donwload Excel Reader and upload to your server. PHP Import Create PHP Import import.php
.
Update Record in MySQL Database
rowcount($sheet_index=0); //read rows from excel datas $success = 0; $failed = 0; for ($i=2; $i<=$rows; $i++) { //import excel datas from row-2 $col1 = $data->val($i,1); //read row datas col-1 $col2 = $data->val($i,2); //read row datas col-2 $query = "UPDATE yourtable SET db_col1='$col1' WHERE db_col2='$col2'"; $result = mysql_query($query); if($result) $success++; else $failed++;} echo "
Successfully: ".$sucess."
"; echo "Failed : ".$failed."
"; ?>
That's simple, right? Just a few steps.