ThEMakeR Posted August 17, 2006 Share Posted August 17, 2006 Hi again,I have developed some code for a PHP navigation system, similar to a tutorial I recently looked at, but I'm not sure how I make the appropriate cat_x.php page appear when a link, <a href.... </a>, is clicked. The code 'script' I am using is:Script:[code]<?phpif ($p == "") { include "v3/catalogue.php"; }elseif ($p == "cat_1.php") { include "v3/cat_1.php"; } elseif ($p == "cat_2.php") { include "v3/cat_2.php"; } elseif ($p == "cat_3.php") { include "v3/cat_3.php"; }elseif ($p == "cat_4.php") { include "v3/cat_4.php"; }elseif ($p == "cat_5.php") { include "v3/cat_5.php"; }else { include "v3/error.php"; }?>[/code]What I need to happen:I need to be able to click a link on a page called "catalogue.php", have the variable(?) $p select the appropriate cat_x.php page and display its contents, its catalogue items rather, on the page.How do I get around this??To help a bit more I am including the full code for my page:[code]<?php include "header.php";?><br /><div align="center"><img src="images/cat_img.gif" alt="Martin & D'almeida antique catalogue 2006" /><br /><font>Click the desired catalogue link to see those items</font><br /><br /><a href="http://www.manddantiques.com/catalogue.php?p=cat_1.php"><img src="images/cat_1.jpg" alt="Urns and Ornaments catalogue of stock" height="140" width="100" /></a><a href="http://www.manddantiques.com/catalogue.php?p=cat_2.php"><img src="images/cat_2.jpg" alt="Carvings and Sculptures catalogue of stock" height="140" width="100" /></a><a href="http://www.manddantiques.com/catalogue.php?p=cat_3.php"><img src="images/cat_3.jpg" alt="Garden Statuary catalogue of stock" height="140" width="100" /></a><a href="http://www.manddantiques.com/catalogue.php?p=cat_4.php"><img src="images/cat_4.jpg" alt="Decorative Items catalogue of stock" height="140" width="100" /></a><a href="http://www.manddantiques.com/catalogue.php?p=cat_5.php"><img src="images/cat_5.jpg" alt="Chimney and Fire Pieces catalogue of stock" height="140" width="100" /></a><br /><a href="http://www.manddantiques.com/catalogue.php?p=cat_1.php">Urns & Ornaments</a><a href="http://www.manddantiques.com/catalogue.php?p=cat_2.php">Carvings & Sculptures</a><a href="http://www.manddantiques.com/catalogue.php?p=cat_3.php">Garden Statuary</a><a href="http://www.manddantiques.com/catalogue.php?p=cat_4.php">Decorative Items</a><a href="http://www.manddantiques.com/catalogue.php?p=cat_5.php">Chimney & Fire Pieces</a><br /><br /><font><u>All items are for sale unless otherwise stated</u></font></div><?php include "footer.php";?>[/code]Have I gone about it the wrong way?! Please spend a small few minutes helping me if you can, thanks very much to anyone who lends a hand. Its very appreciated! Quote Link to comment Share on other sites More sharing options...
Ifa Posted August 17, 2006 Share Posted August 17, 2006 [code=php:0]<?php$p = $_GET["p"];if ($p == "") {....[/code] Quote Link to comment Share on other sites More sharing options...
ThEMakeR Posted August 17, 2006 Author Share Posted August 17, 2006 I might have to start from scratch because I cant get it to work.Anyone got a script they use that will work with a link system? Quote Link to comment Share on other sites More sharing options...
Jenk Posted August 17, 2006 Share Posted August 17, 2006 [code]<?php$p = '';if (!empty($_GET['p'])) $p = $_GET['p'];switch ($p) { case 'cat_1': include $p . '.php'; break; /* snip.. */ default: include 'default.php';}//etc.[/code] Quote Link to comment Share on other sites More sharing options...
Ifa Posted August 17, 2006 Share Posted August 17, 2006 include $p;as?p=cat_1.phpand so on 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.