I want to insert mysql data table values from a excel file , in php.I googled a lot for it and none of them worked . The excel table is like this: The excel file which i want to upload it to mysql
            Asked
            
        
        
            Active
            
        
            Viewed 199 times
        
    -3
            
            
        - 
                    what you tried so far .show the code – JYoThI Jul 07 '17 at 05:08
- 
                    You need to make import function from excel data from excel to mysql database..?? – Dharmendra Singh Jul 07 '17 at 05:10
- 
                    @DharmendraSingh : No no, just use any libraries or other functions for my project. – Shinoy p b Jul 07 '17 at 05:20
- 
                    is that a .csv file? – Sinto Jul 07 '17 at 05:26
- 
                    you need PHPExcel Library to import your excel to database.. http://www.ilovephp.net/php/how-to-import-excel-file-data-into-mysql-database-in-php/ – Dharmendra Singh Jul 07 '17 at 05:31
- 
                    @DharmendraSingh : Got the phpexcel library ,it worked ..thank you. – Shinoy p b Jul 07 '17 at 07:27
1 Answers
0
            
            
        I would suggest save the file in csv format and upload using "Load data infile"
check the mysql documentation here
CREATE TABLE sample 
(
   id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
   rollno INT, 
   admnno INT, 
   name varchar(50),
   dob Date,
   classid INT, 
   guardian varchar(50),
   contactno INT
);
LOAD DATA INFILE '/tmp/sample.csv' 
INTO TABLE sample  
   FIELDS TERMINATED BY ',' 
   OPTIONALLY ENCLOSED BY '"'
LINES  TERMINATED BY '\n'
 
    
    
        Shuchi Sethi
        
- 683
- 7
- 13
- 
                    
- 
                    Okay. Can you change the file to csv format or want to use Excel only? You can use [PHPExcelReader](https://sourceforge.net/projects/phpexcelreader/) if you want you use excel only otherwise use fgetcsv() for csv format – Shuchi Sethi Jul 07 '17 at 05:28
- 
                    OKAY,got your point ,i simply used the phpexcelReader..problem solved – Shinoy p b Jul 07 '17 at 07:25
