Jump to content

all in one


tml

Recommended Posts

Here's a simple example:

 

Place this code on the first line of your index.php:

<?php
if (empty($_GET['page']))
	{
		$_GET['page'] = 'home';
	}
?>

 

Place this code in your content div:

<?php
			if(is_numeric($_GET['page'])) // check if button ACTION is a number.
				{
					$page = $_GET['page'];
					$query="SELECT * FROM `table_in_database` WHERE `id` = '$page';";
					$result = mysql_query($query);
					$inhoud = mysql_fetch_assoc($result);  // MYSQL data to PHP
					echo $inhoud['info']; // Display your content
				}
			else // if not a number then load page from the PAGES folder.
				{
					$_GET['page'];
					include('pages/'.$_GET['page'].'.php'); // name and add .PHP to it
															// wich will result in a 
															// filename in the PAGES
															// folder.
				}

?>

 

Now, make a folder on the root called pages. In this folder are the files stashed like home.php, news.php , allyourfiles.php etc etc. These will be called from the content div.

 

Your buttons (anywhere on your page) must have the following action:

?page=home

Home is referring to your pages/home.php file.

 

Or get the content out of a dabase:

?page=1

 

If anyone feels the need to add a more complicated one with security feel free to do so but i thought this might be a good way to start.

 

Enjoy.

Link to comment
https://forums.phpfreaks.com/topic/126596-all-in-one/#findComment-656177
Share on other sites

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.