PDA

View Full Version : Any php/mysql guys in the house?


Don-Dad
11-17-2005, 12:55 AM
I need some mysql and php help, setting up a database using multiple csv files and then have a searchable database online. Anyone have any tips?

Don-Dad
11-17-2005, 02:26 PM
I think you misspelled, that geek not greek :lol:

Jackson's Dad
11-17-2005, 05:42 PM
I know PHP well, and do ok with mysql (if I have a manual nearby). Are you having trouble importing the CSV files into a mysql database? Or are you trying to have PHP access the files themselves?

If it is the former, then do you use phpMyAdmin (http://www.phpmyadmin.net/)? It makes tasks like that very easy.

Don-Dad
11-17-2005, 05:47 PM
I have messed with phpadmin some, I set up a few databases but my problem is, I'd like to take like 30 csv files, merge them into one mysql database, I guess it would involve mapping the different fields for each csv as they are not all indentical. Then I'd like to make it searchable. Probably end up with 150,000 records, give or take 50,000 :lol:

I'm not asking for too much am I? ;) I have "php for dummies', and I resemble the dummie part. I have a few scripts I am messing with but the hardest part seems to be getting the data into mysql.

ian
12-21-2005, 04:47 AM
To import an Excel file into MySQL, first export it as a CSV file. Remove the CSV headers from the generated CSV file along with empty data that Excel may have put at the end of the CSV file.

You can then import it into a MySQL table by running:


load data local infile 'uniq.csv' into table tblUniq
fields terminated by ','
(uniqName, uniqCity, uniqComments)


The fields here are the actual tblUniq table fields that the data needs to sit in.

Hope that helps.

Don-Dad
12-21-2005, 04:55 AM
Ian, my new friend :)

I found some php script that I was able to use to import data into mysql.

I am on to bigger problems. I have like 40 different csv files all imported inot one mysql database, like 280,000 records total. That part was not so bad. I use an ID field set to auto increment and have that field as the primary key.

I am still learning so my "lingo" might not be correct ;) But my new problem is updating the data from each csv file. I could delete all the data and import the new files. But some of the data get updated rarely while other files are updated weekly. I was told to set up another table in the mysql database and update that table then use that to update the other. I am kind of lost on this new issue :???:

Have any advice?

Thanks :)

ian
12-21-2005, 05:03 AM
Yeah...

I always end up giving out tech advice and giving myself away. Don't even get me started on what a "computer whore" I am. My wife pimps me out to all her friends, for free. "Oh he'd love to fix it". Then it's "WHEN ARE YOU GOING TO GET OFF THE COMPUTER"....that's a whole other thread.

Give me an example of what your DB looks like now, maybe make up some fake tables and data. Infact, tell me what you want to do and maybe I can point you in the right direction. With mySQL you should hever have to do things twice. You can script anything. Shouldn't ever have to move stuff into another table and then move it back.

^^ nvm..I just read what you want to do..

Now, does it all have to be updated in CSV files? Could you just build a little website that can update the data and then export it when you need raw data?

Don-Dad
12-21-2005, 05:17 AM
I feel bad now asking for free advice :oops:

Hopefully this will just take a minute of your time :wink:

I get these csv files from multiple sources so the data structure is not the same. All the csv then get merged into a mysql database. My bro is a programmer of sorts but usess MS SQL and it's just too expensive to get ms sql hosting.

The goal is to take the csv files insert the data into mysql, using the fields I need. I use the data for a search feature on a site and also to display the data. I do not need to update all the files everyday, some weekly, others monthly.

I can get the data into the database using phpmyadmin or this other php script. But updating the data, by this I mean , replacing the existing data with the new stuff, is giving me a headache. The primary key field, ID, using auto increment gives me the problems. I use that field to display the data.

I am pretty much a complete noob to this.

Your previous response was appreciated and do not feel obligated to repsond. I know how it can be a hassle help out with techie stuff without all the proper info (Been there done that)

ian
12-21-2005, 05:24 AM
LOL..I meant for hardware fixing stuff. I don't like having other people's computers in my house. Yeah, that sounded bad. Sorry about that.

Kid and wife are finally asleep so I have 10 minutes to myself to think.

Hmm..trying to think of an easy way to do that...You would have to somehow compare the data with the existing data in the table and only overwrite it if it was changed. I can probably whip something together when I have some time. Is June OK? heh.

Can't WAIT to quit my job in Feb. Going to be so nice to walk into my boss's office and give him that 1 months' notice.

Don-Dad
12-21-2005, 05:30 AM
I'll keep you updated on my progress, my bro might offer up some assistance as well as someone in a techie forum I know. If we can't figure it out, I'll post here again :)

June would be good, it would be a nice birthday present.

I really do appreciate you taking the time to post.

ian
12-21-2005, 05:31 AM
Hey no problem. I'm here to help :)