Jump to content

Question for setting up dynamic database website.. Help Please


blesseld

Recommended Posts

Hey All,

 

I'm looking to get pointed in the right direction to create a more dynamic php website.

What I am trying to achieve is Setting up a database to store my content.  I have done Many Many searches in google, and its all about creating the database.

 

I guess I am after understanding how the data is stored and how to go about doing it...

 

My site is currently setup with a wack of includes, to make things easier to update.  Below is how my index page is setup, I setup a variable to give it a name, and the control.php is where i set all my variables for page_id, title, keywords ...

 

<?php
  $sheet_name = "homepage";
  include("inc/control.php");
?>
<?php include("inc/page-top.php"); ?>

<p>Some content here</p>
<?php include("inc/expand-boxes.php"); ?>
<p>more includes</p>

<?php include("inc/page-bot.php"); ?>

 

I guess I'm just lost on what needs to be done... What I am after is storing my "Content" the code between the page-top and page-bot in a database to act like articles.... or is there a smarter thing to do? 

 

I get the concept of connecting to a database,  Just don't know how the data is stores, and how do I store code and whatnot within the database.

 

Any help on my journey to create a more dynamic php template/website would be very much appreciated,

 

Thanks in advance.

Have you looked at some basic mysql tutorials (if you're planning on a mysql database) ? These would heplp you greatly. You communicate with the datbase using simple queries. An example of retrieving some data is as follows;

 

SELECT * FROM `table`;

 

 

I gues I'm lost on the actual process,  Am I storing all my content within the data base... like the content between my top and bot includes,  or am i storing the actual file within the db?  or, like wrapping my content  between my top/bot includes, creating another file  then storing that in the db....  this is where im stuck

 

It all depends what you want to do really. I use many different options depending on the project size. If I only have a few pages, I may just hard code everything. Something a bit bigger might hold all the page names in the db, and use a single index.php file to control the site. This can then pull certain templates (.html files) depending on the requested page, or get stored cintent from the db.

 

Personally for static page content I'd just use a template folder as you currently are. If you want to store content areas (for example) you can add them to your table, then request the correct data depending on the current page etc...

hrmmm,  I kinda like the idea of storing variables in the db,  ...also the site will be faily large in the end.

 

My folder structure is currently:

forum

images

inc

js

 

index.php

about.php

 

then i want to add a couple folders for different sections...that use different layouts.

 

business

entertainment

...

 

all which are controlled by

control.php...here is a snipet from the file

 

 

	case 'giorge':
{
	$page_id = "101";
	$title ="Title";
	$meta_desc = "desc";
	$meta_key = "keywords";
	$nav_style = "browse";
	$nav_trail_start = "home";
	$nav_trail_root = "browse-places";
	$nav_trail_category = "restaurants";
	$nav_trail_page ="<a class='blue' href='#nogo'>- Giorge Restaurant</a>";
	  include("inc/head.php");
	  include("inc/header1.php");
	break; 
}
default:
{
	echo "";
	break;
}
}

 

case 'giorge'  is the main variable, all my pages have this.

<?php
  $sheet_name = "homepage";
  include("inc/control.php");
?>

 

I htink a db would be good for this control file,  But i guess I want to tackle and learn to load full content within the body just to learn it,  but main use would be for my news section

 

I want to implement a box on the main page that takes "x"amount of characters form the 3 recent news pages, and feed them into my news box on my homepage.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.