Hello everyone and thanks much for your past help! I am an ASP programmer who is trying to get the hang of PHP and I am still having problems with what I figure is a relatively easy task to achieve.
I have a text file that is delimited by chr(25) or end of medium characters and it has two pieces of data that I need to insert into a Category and AdText columns in the MySQL table. Everything seems to work, but it only uploads the first entry into the database and I can't seem to get the looping right. Any suggestions would be very much appreciated.
Here's what I have so far:
<?php
$data = $file('class_text.txt');
$i = 0;
foreach($data as $line) {
$cols = explode(chr(25),trim($line[$i]));
$Category = $cols[$i];
$AdText = $cols[$i + 1];
mysql_query("INSERT INTO SimpleClass (Category, AdText) VALUES ('$Cat','$AdText')");
In the class_text.txt file, there are several entries that start with a category number then a description and the file looks similar to this:
010 some text here 020 some text here 030 some more text here
I need the script to repeat itself after it reads a category and the text and start over on the next category number, then loop and upload each entry to the database. Make sense? I'm just not sure how to do this and I have scoured the Internet on forums and read books and just can't seem to find a good example of how to do this.
Any help would be most appreciated! Thanks!