Jump to content

PHP Dynamic content switching help please


josephsprint

Recommended Posts

Hi,

I followd a very simple tutorial on dynamic content and I can't seem to get it working even though it appeared to be the same. This is my first go at PHP.

Can anyone help me solve what's going wrong.

[a href=\"http://www.josephsprint.co.uk/test/mono/reviews.php\" target=\"_blank\"]http://www.josephsprint.co.uk/test/mono/reviews.php[/a]

following code points to a few include files in the same directory.

[code]
<div id="side1">
<h2>CD Reviews</h2>
<?php switch($id)
{
case ’issue1cd’:
include ’issue1cd.php’;
break;
case ’issue2cd’:
include ’issue2cd.php’;
break;
case ’issue3cd’:
include ’issue3cd.php’;
break;
case ’issue4cd’:
include ’issue4cd.php’;
break;
default:
require ’issue1cd.php’;
}
?>
</div>
[/code]

This is the include file- 'issue1cd.php'

[code]
<ul>
<li>White Light Parade</li>
<li>Ruby Tombs</li>
<li>This Et Al</li>
</ul>
<p>
Issue:
<a href="reviews.php?id=issue1cd">1,</a>
<a href="reviews.php?id=issue2cd">2,</a>
<a href="reviews.php?id=issue3cd">3,</a>
<a href="reviews.php?id=issue4cd">4,</a>
<a href="reviews.php?id=issue5cd">5,</a>
</p>
[/code]

It seems simple enough but I don't know what's wrong.

I would also like to know if I can put my includes into a folder called includes, in that case what does 'case' point to?

Cheers,
Jo
Link to comment
Share on other sites

Hi, Thanks for the replys, the double quote worked perfectly but only when appplied to everything, also when I add the $id = $_GET['id']; it just makes the screen go blank but it works without anyhow.

I don't know what globals are or what on/off means.
Link to comment
Share on other sites

OK

I fixed the syntax of the script, it now looks like:

[code]
<?php switch($id)
{
    case "issue1cd":
    include ('issue1cd.php');
    break;
    case "issue2cd":
    include ('issue2cd.php');
    break;
    case "issue3cd":
    include ('issue3cd.php');
    break;
    case "issue4cd":
    include ('issue4cd.php');
    break;
    default:
    require ('issue1cd.php');
}
?>
[/code]

If I add [b]$id = $_GET['id'];[/b] to the top of the script it stops working all together and just shows a blank page.

Now this is the bit I missed before. The switching isn't actually working anyway, each link just displays the default include even though the address bar changes. I made each include different now to make sure.

Many Thanks
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.