$postvalue) { $e = explode("|", $postkey); if ($e[0] == "line") { $id = $exploded[1]; $_SESSION['lines'][$id]['visible'] = 1; } } header("Location: /"); exit(); } //////////////////////////////////////////////////// DETAIL FILTERING // filtering results for a specific line if (isset($_POST['filterdetails'])) { $lineid = $_POST['line']; $sectionid = $_POST['section']; if ($_POST['action'] == "Update Line") { // set new filtering options foreach ($_POST as $postkey => $postvalue) { $e = explode("|", $postkey); if ($e[0] == "checkbox") { $checkboxid = $e[1]; $checked = 0; // unchecked until proven guilty foreach ($_POST as $postkey2 => $postvalue2) { $e2 = explode("|", $postkey2); if (($e2[0] == "filter") && ($e2[1] == $checkboxid)) { $checked = 1; } } $_SESSION['filters'][$lineid][$sectionid][$checkboxid]['checked'] = $checked; } } } header("Location: /?line=$lineid§ion=$sectionid"); exit(); } //////////////////////////////////////////////////// GET STUFF FROM DATABASE INTO ARRAYS // some variables for this section $tablewidth_detailbar = 785; $tablewidth_details = 600; $tablewidth_details_withtext = 830; $detailbarmax = 20; // max number of pieces in detailbar $querylimit = 20; // limit of results coming from details queries // populate data arrays for each section $sectionnames = array("Browser","Result","Entry Page","Referrer","Page","Platform"); $sectionids = array("browser","result","entrypage","referrer","page","platform"); $queries = array( "SELECT BrowserString as name, Count(*) as value FROM Traffic ", "SELECT Result as name, Count(*) as value FROM Traffic ", "SELECT Path as name, Count(*) as value FROM Traffic ", // entrypage "SELECT Referrer as name, Count(*) as value FROM Traffic ", "SELECT Path as name, Count(*) as value FROM Traffic ", "SELECT Platform as name, Count(*) as value FROM Traffic " ); $queries2 = array( " GROUP BY BrowserString ORDER BY value DESC ", " GROUP BY Result ORDER BY value DESC ", " GROUP BY Path ORDER BY value DESC ", // entrypage " GROUP BY Referrer ORDER BY value DESC ", " GROUP BY Path ORDER BY value DESC ", " GROUP BY Platform ORDER BY value DESC " ); // get data into arrays for each item of each line foreach($_SESSION['lines'] as $line) { $lineid = $line['id']; // get data for each section $queryid = 0; foreach ($sectionids as $sectionid) { $query = $queries[$queryid]; $query2 = $queries2[$queryid]."LIMIT ".$querylimit; $querymiddle = ""; // WHERE and AND section // apply filtering if (isset($_SESSION['filters'][$lineid])) { foreach ($_SESSION['filters'][$lineid] as $filtersectionid => $filtersectionid_array) { if ($filtersectionid != $sectionid) { foreach ($filtersectionid_array as $filteritem) { $filteritemid = $filteritem['id']; $filteritemname = $filteritem['name']; $filteritemvalue = $filteritem['value']; // get db column name for this item if ($filtersectionid == "browser") { $column = "BrowserString"; } elseif ($filtersectionid == "result") { $column = "Result"; } elseif ($filtersectionid == "entrypage") { $column = "Path"; } elseif ($filtersectionid == "referrer") { $column = "Referrer"; } elseif ($filtersectionid == "page") { $column = "Path"; } elseif ($filtersectionid == "platform") { $column = "Platform"; } // where or and depending if ($strlen($querymiddle) == 0) { $querymiddle .= "WHERE"; } else { $querymiddle .= "AND"; } $querymiddle .= " ($column != '".mysql_escape_string($filteritemname)."') "; } } } } $query = $query . $querymiddle . $query2; //echo "

".$query."

"; $result = $db->query($query); if (DB::isError($result)){ $_SESSION['lines'][$lineid]['filters'][$sectionid]['results'] = null; // set this section as null if there are no items in it } else { // clear results unset($_SESSION['lines'][$lineid]['filters'][$sectionid]['results']); // refill results $x = 0; while ($row = $result->fetchRow()) { $filteritemname = $row['name']; $filteritemid = $x; $filteritemvalue = $row['value']; $_SESSION['lines'][$lineid]['filters'][$sectionid]['results'][$x]['name'] = $name; $_SESSION['lines'][$lineid]['filters'][$sectionid]['results'][$x]['value'] = $value; $_SESSION['lines'][$lineid]['filters'][$sectionid]['results'][$x]['id'] = $x; $_SESSION['lines'][$lineid]['filters'][$sectionid]['results'][$x]['checked'] = 1; $x++; } } $queryid++; } // process all the data and calculations for displaying foreach ($sectionids as $sectionid) { // calculate all this stuff only if there are even results if ($_SESSION['lines'][$lineid]['filters'][$sectionid]['results'] != null) { $_SESSION['lines'][$lineid]['filters'][$sectionid]['detailsratio'] = $tablewidth_details / $_SESSION['lines'][$lineid]['filters'][$sectionid]['results'][0]['value']; // calculate percents for bars $_SESSION['lines'][$lineid]['filters'][$sectionid]['total'] = 0; $_SESSION['lines'][$lineid]['filters'][$sectionid]['total_detailbar'] = 0; $x = 0; foreach ($_SESSION['lines'][$lineid]['filters'][$sectionid]['results'] as $result) { $value = $result['value']; $_SESSION['lines'][$lineid]['filters'][$sectionid]['total'] += $value; $x++; if ($x < $detailbarmax) { $_SESSION['lines'][$lineid]['filters'][$sectionid]['total_detailbar'] += $value; } else { break; } } // get percents and pixel widths $total = $_SESSION['lines'][$lineid]['filters'][$sectionid]['total']; $total_detailbar = $_SESSION['lines'][$lineid]['filters'][$sectionid]['total_detailbar']; $detailsratio = $_SESSION['lines'][$lineid]['filters'][$sectionid]['detailsratio']; $x = 0; foreach ($_SESSION['lines'][$lineid]['filters'][$sectionid]['results'] as $result) { // get some variables $value = $result['value']; // now the calculations $percent = $value / $total; $_SESSION['lines'][$lineid]['filters'][$sectionid]['results'][$x]['percent'] = $percent; $percent_detailbar = $value / $total_detailbar; $_SESSION['lines'][$lineid]['filters'][$sectionid]['results'][$x]['percent_detailbar'] = $percent_detailbar; $width_detailbar = $percent_detailbar * $tablewidth_detailbar; $_SESSION['lines'][$lineid]['filters'][$sectionid]['results'][$x]['width_detailbar'] = $width_detailbar; $width_details = $value * $detailsratio; $_SESSION['lines'][$lineid]['filters'][$sectionid]['results'][$x]['width_details'] = $width_details; $x++; } } } } ?>

Measure:

< 12/2/05

11/30/06 >

Visible Lines

$label
"; } ?>

Add a Line

Label:
Color:
  • + -

    "; // tooltip echo "
    "; echo "$name
    "; echo "Value: $value
    "; echo "Percent: $percent%
    "; echo "Included in Line: "; if ($checked == 1) { echo "Yes"; } else { echo "No"; } echo "
    "; echo "
    "; // the bar (that activates the tooltip) echo "
     "; // and now the javascript of the tooltip echo ""; echo ""; $x++; if ($x > $detailbarmax) { break; } } ?>
    "; echo ""; echo ""; echo ""; echo ""; $x++; } ?>
    "; echo ""; // BECAUSE FORMS DONT POST UNCHECKED BOXES! GAH! echo " ".$name."".$value."
     
    $percent%