0

hello fellow developers,

i have built my website, how it works is it includes the header and footer through php and the rest of the content is in its corresponding file, but would it be possble to have the rest of the content in a mysql database and create pages like that dynamically (kind of like wordpress does), and if someone has a spare moment could you show me how this is done?

<? include("header.php"); ?>

--main content goes here

<? include("footer.php"); ?>

Website: http://www.shadowscape.co.uk

Thanks,

Nathaniel Blackburn

Edited by shadowscape: n/a

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

just select the main content from a table and show it

example:

<?php 
include("header.php");
$page = "myPage"; 
include("showPage.php");
include("footer.php"); 
?>

and for showPage.php

<?php 
	$db = new PDO("mysql:host=$host;dbname=$database", $dbUser, $dbUserPasswod);
	$query = "SELECT TXT FROM pages WHERE page = ?";
	$statement = $db->prepare($query);
	$statement->execute(array($page));
	if($statement->errorCode()!="00000")
	{
		$error = $statement->errorInfo();
		throw new Exception($error[2],(int)$error[0]);
	}
	$result = $statement->fetchAll(PDO::FETCH_ASSOC);
	if(count($result)>0)
	{
          echo $result[0]["TXT"];
	}

?>

But even this is a hybrid of procedural and OOP …. Have ever consider to move just to OOP ?

Edited by jkon: wrong PHP start tags at first place

0

Thanks for your help, i managed to make my own navigation system

Nathaniel Blackburn

This question has already been answered. 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.