Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

howto make LOAD DATA INFILE ?

Status
Not open for further replies.

itslogical

Technical User
Jul 1, 2004
7
NL
hi i could use some help with this problem i have..
im making a database of artist with songtitle but the info i have to ad is a lot.

I know for the expert its very easy but for me with absolutely no knowledge of this is abracadabra...
Okay some info.......

the lists i have is all build like this......

Let No Man Put Asunder - First Choice
Primitive Desire - Eastbound Express Way

So songtitle ...then artist.



This is the table at this moment.. ....

CREATE TABLE `hits` (
`id` int(11) NOT NULL auto_increment,
`titel` varchar(250) NOT NULL default '',
`artiest` varchar(250) NOT NULL default '',
`label` varchar(150) NOT NULL default '',
`hp` smallint(6) NOT NULL default '0',
`aw` smallint(6) NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=74 ;


and the page i created to ad the stuff 1 by 1 is like this....


echo"<form action=\"toevoegen.php\" method=\"post\">"
. "Artist:<input type=\"text\" name=\"artiest\" size=\"20\" maxlength=\"30\"><br>"
. "Titel:<input type=\"text\" name=\"titel\" size=\"30\"><br>"
. "Mixnaam:<input type=\"text\" name=\"label\" size=\"30\"><br>"
. "Hoogste positie:<input type=\"text\" name=\"hp\" size=\"30\"><br>"
. "Aw:<input type=\"text\" name=\"aw\" size=\"30\"><br>"
. "<input type=\"submit\" name=\"submit\" value=\"toevoegen\"></form>";


if($submit) {

mysql_connect("localhost","xxxxxxxx","xxxxxxx");
mysql_select_db("xxxxxxxxx");

$insert = "INSERT INTO hits (id,titel,artiest,label,hp,aw)
VALUES ('$id','$titel','$artiest','$label','$hp','$aw')";
$query = mysql_query($insert)or die(mysql_error());
}




but it will take me probably 30 years to do it like this.
so a friend said something like....LOAD DATA INFILE
i would call it a dump file or whatever...


so my question would be....
can someone create this "LOAD DATA INFILE" for me please ?
and if possible complete....?
So i only have to add the lines of artist and songtitle .... ;)
and what i need to do to execute the file....(so the info gets added......

Thanks for any help...
 
You can create a tab delimited file using MS excel.
This file should have one (1) song/artist combination per line.

Then you can use the command:

LOAD DATA INFILE "filename" INTO TABLE hits (titel,artiest)

This will load the data into the table and will default all of the other fields to an empty string or a zero (depending on the field type).

 
well i dont have a clue what it all means.
look at me as someone that doesnt know anything...
i hoped for help and waiting whole day but still nothing....and this email notification doesnt work at all,it doesnt send mails...
 
try something like this:

$insert = " LOAD DATA INFILE "C:/tmp/fileName.txt" INTO TABLE tableName;"
$query = mysql_query($insert)or die(mysql_error());

from the mysql docs:
"The `LOAD DATA INFILE' statement reads rows from a text file into a
table at a very high speed."

i assume i have your data in a file which you want to insert into the database



------------------------
dev at viewmoresoft.com
tools for your database
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top