Jump to content

Archived

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

ThEMakeR

PHP Navigation help

Recommended Posts

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]<?php
if ($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 &amp; Ornaments</a>
<a href="http://www.manddantiques.com/catalogue.php?p=cat_2.php">Carvings &amp; 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 &amp; 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!

Share this post


Link to post
Share on other sites
[code=php:0]<?php
$p = $_GET["p"];
if ($p == "") {
....[/code]

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
[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]

Share this post


Link to post
Share on other sites
include $p;
as
?p=cat_1.php
and so on

Share this post


Link to post
Share on other sites

×

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.