ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello everyone
for the past month Ive been studying php. what a beautifull language. Now I have a question I don't know if I can do this with php or its better doin it with some other language.
My Question:
I have a news section on my website, I'd like to make it dynamic so the content will be read from a seperate file say news.txt so I just have to update my news.txt file.
I don't know if macromedia dreamweaver/MS front page, has that option or not
It would be appreciated if someone can help me with this or just direct me to a link that has some help on this..
The format of the text file matters, a bit. The link the previous poster gave you will get you going, but you might want to parse the incoming file to add html tags such as <p> or whatever.
If you use readfile and need to format, you will have to buffer your output then process the output buffer. It might be easier to use fopen and fread to bring the input file in a line at a time and place it in a string variable, then parse and edit it, then ship it to the output buffer.
There are also security issues with readfile; if you aren't careful then someone "out there" someplace can exploit your script to read unexecuted php files, thereby gaining all the information needed to exploit any vulnerabilities that might exist.
Your call; there are any number of ways to do just about anything in PHP.
In my web development days, I never really got into PHP much. I kept everything to Perl/CGI and HTML.
I essentially did what you are trying to do with everything on my old site: my menu bars on the page were one file, the content body of the page was another file, and so on.
What I see as a joy of Perl/CGI is that it's quite secure (I've heard of there being some "exploitation" risks with PHP), and you don't have to worry about how you structure the content in your *.txt file, you just have to structure the Perl code to handle the content it's reading, and then structure your text file according to how you want it to be read - If you would like an example of this, just let me know =).
have you considered installing a database such as mysql? the effort required to get it going would be comparable to the file based approach, and it would scale a whole lot better..
well I tought of puting it in mysql and just read it from there... but wouldn't be easier to just read it from a .txt or .xml file... security is not an isssue since my mom is going to update the file on daily bases. therefore from my undrestanding so far one way of doing this is just put contents in a file with whatever html tags and read it line by line with php and parse it into my table/section of my webpage.
thanks everyone
I had understood that your mother was going to update this file. Does she speak html?
Putting any needed html tags into the text file is certainly an easy thing to do, but only if the person putting the tags in knows html. Alternatively, it isn't hard to parse a text file to determine which html tags are needed.
here is my questions: I have a table with 2 columns. In first column I have 2 links which by clicking on each link I'd like a different .txt file parses into the second column. I'm not sure how exactly I can trigger a php with hyper links and how I can print the file into the the 2nd column. I know as much as how to trigger it with submit button. any help would be appreciated
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.