a simple php question i can't get answered anywhere.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
joegats916
Forum Newbie
Posts: 4
Joined: Wed Dec 16, 2009 4:54 pm

a simple php question i can't get answered anywhere.

Post by joegats916 »

Okay.. so like the title says, it's simple. At least, I think it's simple. Other people have answered this question with solutions that don't give me a result that I'm looking for so I will try to provide as much information as I can.

I'm designing a basic html website with PHP elements for a very specific purpose. The purpose is this... I'm setting up the page for someone who knows less about PHP and HTML then me, and I want it to be easy for them to make updates to the page without using any code. The solution that I felt was best was to setup a series of text files from which blocks of content on the page would come from. An example of this would be a welcome header followed by a php script which would draw a few paragraphs from a text file to fill the content below the welcome header.

By using the fread command, someone was able to teach me how to display text naturally from a website, the problem is, is that the text is losing the format it had in the text file. The specific format I'm concerned with is the paragraphs. Instead of neatly formatted paragraphs, the data is being displayed without any break. I'm trying to find a way for the information to retain it's paragraphed format without having to add any special code into the text file.

Another important element of the script is that I wont know how many paragraphs there will be in the text file. there may be one, two, five. and the amount of paragraphs may change when a new text file is uploaded to replace the last one as the website is updated.

If I've left any information out, please e-mail me at studiogipsy (at) gmail (dot) com or reply in the forum.

thank you
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: a simple php question i can't get answered anywhere.

Post by AbraCadaver »

I'm pretty sure that I understand what you're doing but some code examples would help. If by paragraph you mean blocks of text separated by linebreaks, then I would do this (no need to use fread()):

Code: Select all

$text = nl2br(file_get_contents('your_file.txt'));
// wherever you want to use it
echo $text;
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
joegats916
Forum Newbie
Posts: 4
Joined: Wed Dec 16, 2009 4:54 pm

Re: a simple php question i can't get answered anywhere.

Post by joegats916 »

YOUR F'ING BEAUTIFUL MAN. My own personal Jesus H.. I have been literally up all night trying to figure out this stupid code. It's like when i was 16 figuring out DOS.. anyway, thanks so much, you really saved me!
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: a simple php question i can't get answered anywhere.

Post by daedalus__ »

lol its a simple concept but something you are going to have to implement yourself thats why you arent getting a good response. people do this all day with blogs and myspaces and whatever twitter. that's all people 'modifying html without any code'

but listen though be really careful with the text files. im curious about what the application is. you could be leaving some pretty big security holes. please dont just copy and paste that.
Post Reply