Hey all,
I want to import data into mysql Database without using Com object using php technique from a Microsoft Excel File?
5 6419
at first glance I'd say that's impossible, you have to read the file format somehow (and since it's a proprietary format…).
Yeh but you can see that
PHP MyAdmin give the option of importing data through Excel File without using Com object. Is there any special technique PHPMyadmin Using or PHPMYadmin has it's own algorithm.
this is beyond my skill level…
Step1 Form: save it as enterfile.php -
-
<form method="post" enctype="multipart/form-data" action="import.php">
-
<table width="628" border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#eeeeee">
-
<tr>
-
<td width="219"><font size=3><b>Selectionner votre fichier *.csv :</b></font></td>
-
<td width="244" align="center"><input type="file" name="userfile" value="userfile"></td>
-
<td width="137" align="center">
-
<input type="submit" value="Envoyer" name="envoyer" >
-
</td>
-
</tr>
-
</table>
-
</form>
-
Step2 create connect script: save it as connect.php -
<?php
-
// paramètres de connexion
-
$hostname_smoby = "localhost"; /
-
$database_smoby = "sample";
-
$username_smoby = "root";
-
$password_smoby = "";
-
$db = mysql_connect($hostname_smoby, $username_smoby, $password_smoby) or trigger_error(mysql_error(),E_USER_ERROR);
-
mysql_select_db($database_smoby)or trigger_error(mysql_error(),E_USER_ERROR);
-
?>
-
Step 3 import.php -
<a name="haut"></a>
-
<?php
-
// vérification sur la session authentification (la session est elle enregistrée ?)
-
// ici les éventuelles actions en cas de réussite de la connexion
-
require_once('connect.php');
-
//===========================================================
-
//
-
// Code de : Xavier Manzoni
-
// Email : kaptain_kavern_23@hotmail.com
-
// Date: 23 Novembre 2004
-
// Objectif :
-
// Selection d'un fichier xls enregistre sous format
-
// CSV (separateur ";") puis enregistrement dans la base.
-
// Base: smoby
-
// Table: bdd
-
//===========================================================
-
-
-
//=========================
-
// Traitement des donnees
-
//=========================
-
-
//recupere le nom du fichier indiqué par l'user
-
$fichier=$_FILES["userfile"]["name"];
-
-
// ouverture du fichier en lecture
-
if ($fichier)
-
{
-
//ouverture du fichier temporaire
-
$fp = fopen ($_FILES["userfile"]["tmp_name"], "r");
-
}
-
else{
-
// fichier inconnu
-
?>
-
<p align="center" >- Importation échouée -</p>
-
<p align="center" ><b>Désolé, mais vous n'avez pas spécifié de chemin valide ...</b></p>
-
<?php
-
exit();
-
}
-
// declaration de la variable "cpt" qui permettra de conpter le nombre d'enregistrement réalisé
-
$cpt=0;
-
-
// importation
-
while (!feof($fp))
-
{
-
$ligne = fgets($fp,4096);
-
// on crée un tableau des élements séparés par des points virgule
-
$liste = explode(";",$ligne);
-
// premier élément
-
$liste[0] = ( isset($liste[0]) ) ? $liste[0] : Null;
-
$liste[1] = ( isset($liste[1]) ) ? $liste[1] : Null;
-
$liste[2] = ( isset($liste[2]) ) ? $liste[2] : Null;
-
$liste[3] = ( isset($liste[3]) ) ? $liste[3] : Null;
-
-
$champs0=$liste[0];
-
$champs1=$liste[1];
-
$champs2=$liste[2];
-
$champs3= $liste[3];
-
-
-
// pour eviter qu un champs "nom" du fichier soit vide
-
if ($champs1!='')
-
{
-
// nouvel ajout, compteur incrémenté
-
$cpt++;
-
// requete et insertion ligne par ligne
-
// champs1 id en general dc on affecte pas de valeur
-
-
$result= mysql_query("INSERT INTO names VALUES('','$champs0','$champs1','$champs2','$champs3')");
-
-
}
-
}
-
-
// fermeture du fichier
-
fclose($fp);
-
-
-
//==================
-
// FIN
-
//==================
-
?>
-
<br /><br />Nombre de valeurs nouvellement enregistrées: <b><?php echo $cpt;?></b>.<br /><br />
-
I wish that help sorry for the frensh explaination inside the php scripts . it was just fast reply .have funn with php
Sign in to post your reply or Sign up for a free account.
Similar topics
by: dave |
last post by:
Hello there,
I am at my wit's end ! I have used the following script succesfully to
upload an image to my web space. But what I really want to be able to do is
to update an existing record in a...
|
by: Damien |
last post by:
Hi to all,
I need to design an import/export system. Data comes from a filemaker
pro DB in a big CSV file. Some alterations are made on the data as it is
imported into my mysql table. Data is...
|
by: jet |
last post by:
Hi,
Maybe this is an easy task, but I'm having a really hard time figuring
out how to do this. I'm a complete newbie to SQL Server.
I have a database dump file from MySQL that's in .sql...
|
by: news |
last post by:
Our production database in an exported textfil runs about 60 MB.
Compressed that's about 9 MB.
I'm trying to import the export into another machine running FC3 and
mySQL 11.18, and it appears as...
|
by: phillip.s.powell |
last post by:
We're looking at a GUI interface for our MySQL DB and I am interested
in MySQL Administrator, however, one of our requirements is to be able
to import/export databases. Is this possible or do I...
|
by: Avi |
last post by:
Hi
I need to read in a large set of text files (9GB+ each) into a database
table based on fixed width lengths.
There are several ways to complete this, but I am wondering if anyone has...
|
by: NewbieSupreme |
last post by:
I'm using PHPMyAdmin on an Apache2Triad install (latest version; 5.x.x,
which installs PHP5 and PHPMyAdmin 2.8 as well). In Access, I exported a
table to a text file, tab-delimited, text qualifyer...
|
by: Randy |
last post by:
Folks:
We have a web-based app that's _really_ slowing down because multiple
clients are writing their own private data into a single, central
database. I guess the previous programmer did...
|
by: GarryJones |
last post by:
(I am sorry if this is the wrong group for this posting, I cant find a
group on usenet for phpmyadmin, but maybe someone would be nice enough
to answer me anyway....)
I need to import data into...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |