Jump to content

How to display external text on a web page


ninevolt1

Recommended Posts

I have an html file with numerous news articles in it. It's formatted somewhat like this:

 

<!--ARTICLE-->

Article 1 contents and stuff.

 

<!--ARTICLE-->

Article 2 contents and stuff.

 

<!--ARTICLE-->

Article 3 contents and stuff.

 

<!--ARTICLE-->

Article 4 contents and stuff.

 

<!--ARTICLE-->

Article 5 contents and stuff.

 

and so on. It has about 20 articles in it. I need a PHP script that will get the articles from that file to display on my web page. But I also need the script to only display articles 5 through 15. How can I do that? So far I've only been able to find solutions that display all the articles.

Link to comment
Share on other sites

would be best to use a mysql database, have the data from the articles in a database with fields like ID, title, date, author, content, etc and then have the php connect to the database and grab the row (based on $_GET info) and then display it...

 

this will allow you to have one webpage be able to display countless articles

 

as for the 5-15 or wahtever...  look up "php pagination"

Link to comment
Share on other sites

Thanks for the reply. The articles do have the ID and title etc. but I just didn't write them above in the interest of saving time and space.  I don't really have the know how to start using MySQL. Right now the html file with all the articles is generated by another PHP page. I've found scripts that will display by HTML file but I want to be more selective (but not too selective) about what gets displayed. I basically need a script that says open article.html file, ignore first 4 articles, print all the other articles.

Link to comment
Share on other sites

1st read file in string

2nd explode string on <!--ARTICLE-->

3rd do with array elements what you want

 

Thanks for the reply. Unfortunately you overestimate my PHP abilities. I was hoping someone could write out the lines of code. I figured, and could be extremely wrong, that it would just take a few lines to get it done. With what you wrote above, is that like a few lines of code or are we talking pages?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.