Import excel data into php-mysql records
To import excel data into php-mysql records
- Create a table with required fields.
- Make database connection.
- Open CSV file and read data.
- Create and run the sql query till the end of the file.
// Connect to your database mysql_connect('localhost','username','password'); mysql_select_db('dbname'); // Open the file for reading $file = "sample.csv"; $handle = fopen($file,"r"); do { if($data[0]){ $q="INSERT INTO products (name, brand, price) VALUES ( '".mysql_real_escape_string($data[0])."', '".mysql_real_escape_string($data[1])."', '".mysql_real_escape_string($data[2])."' )"; mysql_query($q); } } while ($data = fgetcsv($handle, 1000, ","));
Import excel data into php-mysql records
Reviewed by JS Pixels
on
December 30, 2010
Rating:
nice blog.
ReplyDeletePlease Visit My Blog..
Lyrics Mantra
how to send the more than 1000 mail from excel sheet sheet at a time as click on send mail button in php ?
ReplyDeleteplease help me ........
santoshverma212@gmail.com
Download excel sheet reader from
ReplyDeletehttp://sourceforge.net/projects/phpexcelreader/
and after reading records use mail() function inside loop. This will surely help you.
Altaf hussain, good works.. :P
ReplyDelete