Tjazi Posted November 30, 2007 Share Posted November 30, 2007 Ok, so I have a massive file of information, now FIND AND REPLACE techniques do not work, so making a PHP script, should. Now I have the information like so (exactly how it is in the file) id<br> name<br> title<br> album<br> year<br> id<br> name<br> title<br> album<br> year<br> id<br> name<br> title<br> album<br> year<br> So on and so forth for about 4,500 times. (Obviously the values are set in the text file though). Now I am wondering how will I go about putting it into my database? I know how to insert: mysql_query("INSERT INTO listings VALUES('','','','','')"); But not sure how to make my text file do it in the format it is in. I need to find a solution by tommorow morning at the latest, any ideas please?? Note 1: The <br> tags are in the file. Note 2: The insert command will insert the information from every 5 lines. Quote Link to comment Share on other sites More sharing options...
eon201 Posted November 30, 2007 Share Posted November 30, 2007 What type of file is it? Quote Link to comment Share on other sites More sharing options...
revraz Posted November 30, 2007 Share Posted November 30, 2007 And you want to keep the <br> tags in the DB? Quote Link to comment Share on other sites More sharing options...
Tjazi Posted November 30, 2007 Author Share Posted November 30, 2007 And you want to keep the <br> tags in the DB? Nope. What type of file is it?It was a PDF file, but I converted it to a TXT file, so it's a .txt file. Quote Link to comment Share on other sites More sharing options...
marcus Posted November 30, 2007 Share Posted November 30, 2007 You can easily modify this to fit what you need. <?php $string ="id<br> name<br> title<br> album<br> year<br> id<br> name<br> title<br> album<br> year<br> id<br> name<br> title<br> album<br> year<br>"; $string = explode("<br>", $string); $x=1; foreach($string AS $alone){ echo $alone . " "; if($x == '5'){ echo "<br>\n"; $x=0; } $x++; } ?> Of course, if it's a file. Just change the $string variable to $string = file_get_contents('file.txt'); My results were: id name title album year id name title album year id name title album year Quote Link to comment Share on other sites More sharing options...
Tjazi Posted November 30, 2007 Author Share Posted November 30, 2007 But how would I get them into a mysql_query command? I've tried $string[0] and $alone[0] but none have worked. Quote Link to comment Share on other sites More sharing options...
Tjazi Posted December 1, 2007 Author Share Posted December 1, 2007 *bump* Please guys, it's the morning now and it's pretty urgent. :s Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.