0

hello again,

i have one more problem im trying to get past, i have a url structure like this....

products.php?page=scripts

how would i make a multiple variable so i can also use this....

products.php?pid=sscfa

but not at the same time, either one or the other, i have attached the code for the page below and if anyone has a moment to spare it would be great if you could tweak my code in order to do as stated above, thanks for your time and i look forward to hearing from you guys, this community rocks!

<?

$page = $_GET['page'];

$category = "products";
$template = "resources/templates/$category/$page.php";

//Dynamically Create Page Structure

	include("resources/includes/header.php");

	if (file_exists("$template")) {

		include("$template");

	} else {

	echo("<div class=\"content-box\">");
	echo("<h4>Ooops</h4>");
	echo("<p>Page Not Found</p>");
	echo("</div>");

	}

//End Of Structure Creation

include("resources/includes/footer.php"); 

?>

Nathaniel Blackburn

Edited by shadowscape: n/a

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by teedoff
0

i think i have come up with something, it seems to do the trick but im not sure if its the correct way of doing it...

<?

$page = $_GET['page'];
$product = $_GET['product'];

$category = "products";
$template = "resources/templates/$category/$page.php";

if ( empty( $page) && empty( $product) ) { 

	include("resources/includes/header.php");
	
	echo("<div class=\"content-box\">");
	echo("<h4>Ooops</h4>");
	echo("<p>Page Not Found</p>");
	echo("</div>");
	
	include("resources/includes/footer.php"); 

} elseif (empty($page)) {

//Dynamically Create Page Structure

	include("resources/includes/header.php");

	if (file_exists("$template")) {

		include("$template");

	} else {

	echo("<div class=\"content-box\">");
	echo("<h4>Ooops</h4>");
	echo("<p>Product Not Found</p>");
	echo("</div>");

	}

	//End Of Structure Creation

	include("resources/includes/footer.php"); 


} elseif (empty($product)) {

//Dynamically Create Page Structure

	include("resources/includes/header.php");

	if (file_exists("$template")) {

		include("$template");

	} else {

	echo("<div class=\"content-box\">");
	echo("<h4>Ooops</h4>");
	echo("<p>Page Not Found</p>");
	echo("</div>");

	}

	//End Of Structure Creation

	include("resources/includes/footer.php"); 

}

?>

Nathaniel Blackburn

0

i have no idea what im doing now, haha.

im trying to create a dynamic page structure for products but using my existing one so i dont have to create too many pages, i was thinking of using mysql for the products but pages are template based as it works better and is less dangerous than adding php code into mysql.

Nathaniel Blackburn

0

Adding php code into mysql?? not sure what you mean.

There is actually a PHP forum here, which is where this thread should be. But aside from that, dynamic pages can and do work with databases.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.