Hi All,
I am trying to create Navigation Trail, so as Clicks are made from One (Php Page) to Another, the URL needs to be Copy and stored into the array.
Any headstart will be great.
Thanks.
| SitePoint Sponsor |


Hi All,
I am trying to create Navigation Trail, so as Clicks are made from One (Php Page) to Another, the URL needs to be Copy and stored into the array.
Any headstart will be great.
Thanks.
You need a method to identify the user from page to page (sessions or IP) and a method of storage (either the file sytem or a datebase). Once you have established that the code is very simple.
Location: Alicante (Spain)... Hot and Sunny...
Texas Holdem Poker Probability Calculator | DNS test
Avatars | English Spanish Translation | CAPTCHA with audio
Email | PHP scripts | Cruft free domain names | MD5 Cracker


Actually Page retrives data from the Database, Example Cars:
Such as Cars -> GM -> Oldsmobiles -> Cutless -> 1999
or Cars -> Honda -> Pilot -> Yr 2000
or Cars -> Toyota -> Camry -> yr 2000
etc. etc. etc.
I just want to know how to copy URL & put into the Array which will be created on the fly an not stored into the database.
Thanks.
PHP Code:<?php
session_start();
$_SESSION['history'][] = $_SERVER['PHP_SELF'];
// or maybe this if you need the query string
$_SESSION['history'][] = $_SERVER['REQUEST_URI'];
?>


Thanks a lot.
I need to try this out.


So I started new session and I presume it stores URL in the Session ($_SESSION['history'][]) variable, how can I print this variable???clamcrusher Wrote:
<?php
session_start();
$_SESSION['history'][] = $_SERVER['PHP_SELF'];
?>
I did try following:
But it does not print the array. I need to print the URL as many time as php page is submitted to itself.PHP Code:session_start();
$_SESSION['history'][] = $_SERVER['PHP_SELF'];
$test = array($_SESSION['history']);
echo $test;
Thanks.


Just as a basic output. You an then refine it to add your >> bitsPHP Code:foreach($_SESSION['history'] as $output) {
echo $output;
}
Mike Swiffin - Community Team Leader
Only a woman can read between the lines of a one word answer.....
I started out with nothing... and still got most of it left!


You must use something like for...each cycle to print all the adressesOriginally Posted by jjdave
![]()


Thank You.
For...Each cycle works well.
There is one BUT. When I Refresh (the page) or use Brower Buttons (Back or Forward) it also appends those URLs as well. Is there a any way to trap that error?
Thanks a lot. I did achieve my objective with For...Each.
it depends how you want to eliminate the duplicate entrys.
by default, the array entries will be sorted in the order they were added to the array.
some ways to do it:
use array_unique()
this may affect the sort order in a way that may be desireable, or not desireable to you.
another way could be only add an entry to the history if it does not already exist
PHP Code:
if (!in_array($_SERVER['PHP_SELF'], $_SESSION['history'])) {
$_SESSION['history'][] = $_SERVER['PHP_SELF'];
}
but doing these things are now making this into a list of visited pages, not a history of their click path. im not sure if thats what you want.


You are correct, I do not want List but I do want Click Path.clamcrusher Wrote:
but doing these things are now making this into a list of visited pages, not a history of their click path. im not sure if thats what you want.
You all have given me main Points or Proper Sentex. Now I need to plug in the info properly.
Thank You.
Bookmarks