Jump to content

Dynamic Page Creation


MinusMyThoughts

Recommended Posts

i'm within inches of completing my first content management system. this is my last step before i just start adding bells and whistles to it......i'm trying to create a page where the user can upload an article or blog that will be saved in a database......i'm trying to then figure out how to create a page where the URL will have variables in it that the page will read to determine what to display. something like:http://www.mysite.com/articles?id=24where the "id=24" would be my article ID in the database. i know this is possible, and i found a tutorial on it, but i can't seem to get it to work. i've never dealt with .htaccess or even $_GET variables before, so i'm in totally foreign territory here......i'll try to explain where i'm at right now......my .htaccess file is in the site's root directory (which is a subdirectory on my host's server). i checked into it, and from what i can tell, the host DOES support .htaccess and mod_rewrite. the tutorial i found said i would need an .htaccess file, a file called croute.php (it implements the mod_rewrite. i think.), and my file that will use the $_GET variables (in this case, index.php; placed in mysite.com/articles)......my .htaccess file looks like this:

RewriteEngine OnRewriteRule articles/(.*) index.php?parameters=$1

...my croute.php looks like this:

<?php$params = array();function Router(){	global $params;	$explode = explode("/", $_GET["parameters"]);	for($i=0; $i < count($explode); $i++){		$params[$explode[$i]] = $explode[$i+1];		$i++;	}}Router();?>

...and my file to use all of this (just a test to see if it works for now) looks like this:

<?php include("croute.php")?><html><head><title>Let's View An Article!</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><?phpforeach($params as $x1 => $x2){	echo $x1.": ".$x2."<br />";}?></body></html>

...now, i'll be the first to admit that i have no idea what's going on. i don't know if i'm even on the right track. any help at all is HUGELY appreciated...love,jason

Link to comment
Share on other sites

i'm not sure is this what you need, here i have modified one from my web page with pretty url's, but this is simpler - only with one parameterwww.example.com/articles/24 will be rewritten to www.example.com/articles.php?id=24.htaccess file

RewriteEngine OnRewriteRule ^articles/(.+)/?$ articles.php?id=$1

articles.php

<?echo "selected article id is: ";echo $_GET["id"];?>

put these 2 files in www roothope it suits your needs

Link to comment
Share on other sites

as it would turn out, i was travelling in the absolute wrong direction when i was trying to create my article library......i also didn't make any sense in asking the question......so. what i ended up doing was using a $_GET variable (i figured out how they worked) to feed the article title to my database, which then pulls up the article on a separate page......if that didn't make any sense, you can look at it HERE. click on the "more" link for the article "Let Go Of The Rock" to see how i used the $_GET variable......thanks for trying. sorry i don't make more sense...love,jason

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...