Domanda

I'd like to import into my MySQL database some text files (like news, etc.). Which is the best way to format the chart?

Those file are text file (.txt) with news content. Then I post those files on my homepage. The first line of the original text file is the title, other lines are the text.

Which is the best way to extract those file and post them properly? Should I create 2 coloumn, post the title (first class) on the first coloumn and the rest of text on the second coloumn?

È stato utile?

Soluzione

Yes create a MySQL table called "news" with fields id (int, auto increment), title (varchar 255) and body (mediumtext).

Then use file to get an array of lines in the text file, and insert into the table with title being the first element in the array and the rest in body.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top