ninevolt1 Posted August 12, 2009 Share Posted August 12, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/169865-how-to-display-external-text-on-a-web-page/ Share on other sites More sharing options...
smerny Posted August 12, 2009 Share Posted August 12, 2009 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" Quote Link to comment https://forums.phpfreaks.com/topic/169865-how-to-display-external-text-on-a-web-page/#findComment-896132 Share on other sites More sharing options...
ninevolt1 Posted August 12, 2009 Author Share Posted August 12, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/169865-how-to-display-external-text-on-a-web-page/#findComment-896139 Share on other sites More sharing options...
sasa Posted August 12, 2009 Share Posted August 12, 2009 1st read file in string 2nd explode string on <!--ARTICLE--> 3rd do with array elements what you want Quote Link to comment https://forums.phpfreaks.com/topic/169865-how-to-display-external-text-on-a-web-page/#findComment-896168 Share on other sites More sharing options...
ninevolt1 Posted August 12, 2009 Author Share Posted August 12, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/169865-how-to-display-external-text-on-a-web-page/#findComment-896172 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.