Women in Technology

Hear us Roar



Article:
  Arrays in PHP: Part 2
Subject:   thanx,a nd a hard question with array's
Date:   2002-12-23 10:54:41
From:   anonymous2
I want to thank you for this article, i'm making a script for logging visitors, but I also want to know the way they follow through the site, and that's the problem.


This is the function I have made til now, it works but it only tells me which pages are under volgnr 1, volgnr 2 etc. I want to show things like this:
page1-page 2-page3
|_page 5-page 6


but now I get
volgnr1
-page 1
volgnr2
-page 2
-page 5
volgnr3
-page 3
-page 6


This is the code:
<?PHP
function pageroute($aantalpaginas){
/* functie in testfase voor een verzameling van de hits om zo de paginaroutes te bepalen die de bezoekers volgen door de site. */
/* de array vullen met de gegevens uit de database, werkt correct voor zover getest */
/* Alle unieke bezoekers ophalen uit de db */
$sql="SELECT id FROM bezoekers";
$result = mysql_query($sql);
/* voor alle unieke bezoekers de hits ophalen */
while ($row = mysql_fetch_object($result)){
$hitsql="SELECT page, volgnr FROM hits WHERE user='".$row->id."' ORDER BY volgnr ASC";
$hitresult = mysql_query($hitsql);
/* alle hits in volgorde in de array plaatsen */
while ($hitrow = mysql_fetch_object($hitresult)){
$route[$hitrow->volgnr][]=$hitrow->page;
}
}


$nivo=1;
foreach ($route AS $key => $array)
{
echo 'Stap: '.$key.'
';
foreach (array_count_values($array) AS $page => $count)
{
echo '|_page:'.$page.'('. $count.'x)
';
}
echo "
\n";
}

}
?>
volgnr=follownumber (dutch)
If you have an idea please mail me at dj_lucv@hotmail.com