Forums

PHP

This topic is locked

Dynamic Links ?

Posted 20 Jul 2006 01:27:25
1
has voted
20 Jul 2006 01:27:25 paul de posted:
Hello,
I am relatively new to all this but will explain as best I can.
I have built a site that has a main link page, call it PageA. This page has links on it that link to PageB. Depending on which link is selected on PageA, the data on PageB changes (since the data in PageB is retrieved from a MySQL database). All this works fine.
Now my problem is, i need to create a few more pages, say PageC and PageD that can be accessed from PageB. However, the information I want displayed in PageC and PageD needs to relate to the same information in PageB.
As an example: I am now on PageA and select the link Client1. I am taken to PageB which contains basic information for Client1 that has been retrieved from a MySQL database table. But now I want to have links on this page that can take me to more detailed information about Client1 (but only this client).
If you have managed to understand this explaition I would greatly appreciate instructions on how to accomplish this. If you require further information please let me know. The only thing that I can think this would be called is a "dynamic link" ie: a link that changes depending on which link was previously selected.
I am using Dreamweaver MX with the pages being PHP accessing a MySQL database.
Thanks,
Paul

Replies

Replied 20 Jul 2006 17:24:32
20 Jul 2006 17:24:32 Roddy Dairion replied:
A simple way to do it is to pass a page id in the link as param lets call it pageA.php?paramname=A. Now you filter this by checking
<pre id=code><font face=courier size=2 id=code>
$paramname = $_GET['paramname'];
if ($paramname == "A"
{
$link = "pageB.php?param=B";
}
elseif($paramname == "B"
{
$link = "pageC.php?param=C";
}
</font id=code></pre id=code>
Then you can use $link in you ahref tag in html. <pre id=code><font face=courier size=2 id=code>&lt;a href="&lt;?=$link?&gt;"&gt;Next Page&lt;/a&gt;</font id=code></pre id=code>
There are more complicated ways of doing this but this is just an instruction on how it can be done simply.

Reply to this topic