By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,389 Members | 2,010 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,389 IT Pros & Developers. It's quick & easy.

how to upload excel file and its data to be stored into phpmyadmin

P: 4
hi there,

how to upload an excel file and its data to be stored into database(phpmyadmin) using php.

Dec 26 '13 #1
Share this Question
Share on Google+
9 Replies

Expert 100+
P: 1,035
This cannot be done because phpmyadmin is not a database.

According to wikipedia:
"phpMyAdmin is a free and open source tool written in PHP intended to handle the administration of MySQL with the use of a web browser."

But you probably do mean a mysql database ;-)

Than the question is how should the data in your excel file be 'converted' to this database?

Where/how do you store your tablenames/columnnames/data?

But maybe this can help you:
MySQL for Excel
Dec 26 '13 #2

P: 11
yes it is possible.use Spreadsheet_Excel_Reader,search in google how we upload excel file in php using excel_reader_search.
Dec 26 '13 #3

P: 4
yea phpmyadmin is a server tool to access and manage the db's on mysql servers. thanks for correcting me:)

in that link, by manually importing/exporting of excel data into mysql., such things has given.

what i required is that at by run time excel file has to uploaded and stored into database. check out my attachment, the sample format that to be stored.

to Mukesh : i've seen something about php_excel_reader, its very much useful for reading and writing xls files from php. but while uploading, how can i convert my excel datas into db?

Attached Files
File Type: xlsx Book2.xlsx (9.7 KB, 402 views)
Dec 28 '13 #4

Expert 100+
P: 1,035
If you want to read the data from your excel file, you should google for a script..... "php reading xlsx"

There are lots of examples on the internet...
Download, and inspect the code to find out how they do it...
Dec 28 '13 #5

Expert Mod 5K+
P: 5,397
You will need show us your work.
Please format your script using the [CODE/] button.

We can help you fine tune code, even locate and correct errors provided the basic trouble shooting has been done; however, we normally do not write completed code nor provide finished project (the exceptions usually being after a lot work or something that is really obscure).
Dec 28 '13 #6

P: 4
Look out these sample codes Luuk and zmbd

html code to set upload

Expand|Select|Wrap|Line Numbers
  2. <div id="mainbody">
  3.     <form method="post" action="e2.php" enctype="multipart/form-data">
  4.         <input type="file" name="file" /> <br />
  5.         <input type="submit" name="submit" value="Submit" />
  6.     <form />
  8. </div>
php script to store uploaded excel data

Expand|Select|Wrap|Line Numbers
  1. $conn = mysql_connect("localhost","root","") 
  2. if (!$conn) 
  3. {
  4.   die('Not connected : ' . mysql_error());
  5. }
  6. $db_selected=mysql_select_db("dbname",$conn);
  7. if (!$db_selected) 
  8. {
  9.   die ('Can't use db : ' . mysql_error());
  10. }
  12. if(isset($_POST['submit']))
  13. {
  14.     $file = $_FILES['file']['tmp_name'];
  16.         $handle = fopen($file,"r+");
  17.     print_r(fgetcsv($file));
  18.         while(($fileop = fgetcsv($handle,1000, ",")) !==false)
  19.     {
  21.         $Name = $fileop[0];
  22.         $Surname = $fileop[1];
  23.         $Address = $fileop[2];
  24.         $e-mail = $fileop[3];
  26.         $sql = mysql_query("INSERT INTO csv (Name,Surname,Address,e-mail) VALUES('$Name','$Surname','$Address','$e-mail')");
  27.     }    
  28.         if($sql)
  29.         {
  30.             echo 'data uploaded succesfuly';
  31.         }
  33. }
everything seems correct? but not working. help this out.
Dec 30 '13 #7

Expert Mod 5K+
P: 5,397
OK, what are the issues with the code you posted?
Receiving an error - which and what line?
Only working partially, then what is and is not the code doing for you?
Help us to help you...

As Luuk pointed out, if we wanted sample code, there's tons of it online available for a simple search; however, this isn't our project, it yours, and we're willing to help you with specific issue(s) just not do the work for you.
Dec 30 '13 #8

P: 4
thanks for ur willingness. i really appreciate u.

file is getting uploaded but not storing into db. so at line 26 i added if..else to check whether query is executing or not, then it returns 'Query was empty'.

i was on search, then i found these code, it solved my problem.

Dec 31 '13 #9

Expert 100+
P: 1,035
hmm, it seems to be difficult to post some code, and give a proper linenumber where things stop working.

When asked some people start Googling, and change their original problem from:
"how to upload excel file and its data to be stored into phpmyadmin"
"Upload CSV and Insert into Database Using PHP/MYSQL"

But i'm glad your problem is solved.... ;)
Dec 31 '13 #10

Post your reply

Sign in to post your reply or Sign up for a free account.