Mystixs Posted January 25, 2007 Share Posted January 25, 2007 Hey all. Sorry for making this my first post but I can't find anything to help me. And a friend said you guys could.So, heres my problem.I want to take this page here: http://movoda.net/api/csvranks.html and parse the text from it and place it on a Mysql Database on my host here: http://mrc.110mb.com/testIt will be done to make a more sophisticated highscores page for the game.Once its in the database I can retrieve it and such myself. I just need to know how to parse the text on the Movoda.net website and put it into a mysql database. I have a table set up. With 4 fields. It's all ready just need to parse it. And I don't know how.ANY help is appreciated.Thanks,-Mystixs Link to comment https://forums.phpfreaks.com/topic/35611-parsing-text-then-inserting-it-into-a-database/ Share on other sites More sharing options...
artacus Posted January 25, 2007 Share Posted January 25, 2007 Use fopen() to get the file fgetcsv() to break each line apart. Then write your query. Link to comment https://forums.phpfreaks.com/topic/35611-parsing-text-then-inserting-it-into-a-database/#findComment-168678 Share on other sites More sharing options...
wasimsohail Posted January 25, 2007 Share Posted January 25, 2007 I hope this will work$url="http://tech.groups.yahoo.com/group/strangescience/members?start=11&group=sub"$data=file_get_contents($url);$lines=explode("\n",$data);foreach($lines AS $line ){ $final_data=explode(",",$line); $data1=$final_data[0]; $data2=$final_data[1]; $data3=$final_data[2]; $data4=$final_data[3]; $data5=$final_data[4]; $query="INSERT INTO table VALUES('id','$data1','$data2','$data3','$data4','$data5')"; //Then execute this query. } Link to comment https://forums.phpfreaks.com/topic/35611-parsing-text-then-inserting-it-into-a-database/#findComment-168714 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.