tml Posted October 1, 2008 Share Posted October 1, 2008 HI, i where wondering how to make more pages in one like. index.php?page=1 or something like that... if any can help me with the code i be more than happy. im new to php. so i would like the code so i can just copy and paste, and i would like to know how my link should be etc. <a href index.php?page=1.... Quote Link to comment Share on other sites More sharing options...
Delight Posted October 3, 2008 Share Posted October 3, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.