doubledee Posted August 6, 2011 Share Posted August 6, 2011 I would like to convert my static articles which are separate .php files and put them in a database. 1.) What do I use for a "landing page" for my articles where I swap artciles in and out? 2.) How exactly do I swap in and out articles? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/244059-database-driven-articles/ Share on other sites More sharing options...
AbraCadaver Posted August 6, 2011 Share Posted August 6, 2011 Normally you have something like articles.php and append a get query string to it. You can then read the vars there and load the correct article from the db. Goto articles.php?id=1 query db table articles where id = $_GET['id'] Not sure if that's what you're asking. Quote Link to comment https://forums.phpfreaks.com/topic/244059-database-driven-articles/#findComment-1253490 Share on other sites More sharing options...
doubledee Posted August 7, 2011 Author Share Posted August 7, 2011 Normally you have something like articles.php and append a get query string to it. I am sooo confused the more I think about this all?! :-\ Currently I have a home page of: w w w.MyWebsite.com (aka "index.php") My articles can be found at: w w w.MyWebsite.com/articles/how_to_create_dynamic_pages.php w w w.MyWebsite.com/articles/using_mod_rewrite_automate_things.php w w w.MyWebsite.com/articles/tips_for_secure_code.php The articles are physical files I created and named and put in my "articles" directory. ---- So you are saying I would have a: w w w.MyWebsite.com/articles/index.php and then I would append onto it: ?id=1 ?id=2 ?id=3 Is that right? I think where I am getting confused is how this conversation relates to my larger website. Currently, I have a Home Page which is a hodgepodge of article-teasers, links etc. Then I have an "Articles Home Page" which lists all of my articles by including a Heading, Thumbnail, Teaser Paragraph, and link to the actual article. Like I said, right now, I have a physical file for each article and it is named something like "using_stylesheets_to_simplify_your_life.php" How do I incorporate what you are talking about into all of this?? You can then read the vars there and load the correct article from the db. Goto articles.php?id=1 query db table articles where id = $_GET['id'] Not sure if that's what you're asking. Debbie Quote Link to comment https://forums.phpfreaks.com/topic/244059-database-driven-articles/#findComment-1253549 Share on other sites More sharing options...
trq Posted August 7, 2011 Share Posted August 7, 2011 This post should explain the theory. Just imagine however that the index.php referred to is your page which lists all your articles and then the profiles.php page is article.php used to display an individual article. You could even further optimize this setup using mod_rewrite so that your articles still use links such as using_mod_rewrite_automate_things.php. You would need however to pass the article title through the url instead of a simple id. Quote Link to comment https://forums.phpfreaks.com/topic/244059-database-driven-articles/#findComment-1253593 Share on other sites More sharing options...
doubledee Posted August 7, 2011 Author Share Posted August 7, 2011 This post should explain the theory. Just imagine however that the index.php referred to is your page which lists all your articles and then the profiles.php page is article.php used to display an individual article. I'm getting ready for bed, but on initial inspection, I think that example will be a big help! You could even further optimize this setup using mod_rewrite so that your articles still use links such as using_mod_rewrite_automate_things.php. You would need however to pass the article title through the url instead of a simple id. Ideally, I'd like to keep the same "look and feel" that I currently have, but leverage using MySQL. That means I would have a page that lists articles with a short summary of each ("a_index.php"), and then each article would have a URL which is self-documenting (e.g. "w w w.MyWebsite.com/articles/switching_to_css3.php") and the URL would make it look like there is a file located ina an "articles" directory even though the article is now actually in my MySQL database. How hard will that be to do? Lastly, will you be online earlier in the day tomorrow? (Not sure where you are located?) I would *really* like to get this done tomorrow (or sooner) so I can get back to fixing my "Add a Comment to an Article" module?! Thanks a bunch so far!! Debbie Quote Link to comment https://forums.phpfreaks.com/topic/244059-database-driven-articles/#findComment-1253601 Share on other sites More sharing options...
trq Posted August 7, 2011 Share Posted August 7, 2011 How hard would it be to do? That really depends. This is the kind of thing I could knock together in about 5 - 10 minutes, your time may obviously vary though. As for when I'll be on here, I'm on here quite allot. Though there are many people who could answer your questions. Quote Link to comment https://forums.phpfreaks.com/topic/244059-database-driven-articles/#findComment-1253605 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.