Jump to content

Using PHP to generated different content to a single page.


iconicCreator

Recommended Posts

Good day everyone!

 

I know this is possible but I do not know how to do it.

 

I have a single page, this page has no dynamic content.

 

I have a set of links. What I need is to have content placed on the page based on the link the user clicks.

 

Example: I have pictures of animals. When the user click a Zebra, the Zebra info is placed on the page.

 

So the page does not change, meaning the content on the page changes but not the page it self.

 

The idea is instead of creating different html pages for each animal profile, the profile is generated to the page from a php include file.

 

Is is this possible?

 

Can anyone, some one please point me to how I can get this going.

 

 

Thanks everyone!

 

 

IC

I think what you are trying to do is change the links in a way that when you click on the link it shows on the same page?

 

Try:

 

echo "
<table>
<tr>
<td>";
echo "<a href='index.php?p=somewhere"> Somewhere </a>";

echo"
</td>
</tr>
";
$somewherevariable = $_GET['p'];
if(isset($somewherevariable))
{
$path = "foldername/" . $somewherevariable . ".php";
}
include ($path);
echo"
<tr>
<td>
";

echo"
</td>
</tr>";

 

Hope this helps you. Just reply if you need help.

I think what you are trying to do is change the links in a way that when you click on the link it shows on the same page?

 

Try:

 

echo "
<table>
<tr>
<td>";
echo "<a href='index.php?p=somewhere"> Somewhere </a>";

echo"
</td>
</tr>
";
$somewherevariable = $_GET['p'];
if(isset($somewherevariable))
{
$path = "foldername/" . $somewherevariable . ".php";
}
include ($path);
echo"
<tr>
<td>
";

echo"
</td>
</tr>";

 

Hope this helps you. Just reply if you need help.

 

Thank you very much for your time and effort!

I know a bit of PHP so I can understand the codes a little.

 

I seem to be understanding most except the somewhere variable.

Will the somewhere variable contained the content that is written when the link is click?

 

example:

<?php $somewherevariable = "animal profile"; ?>

 

Thanks again!

 

IC

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.