duannaozhao4626 2011-04-08 20:35
浏览 47

将日志数据限制为仅特定结果

Hi so i have a touchscreen that allows guests and users learn more about our company. On the Main Homepage there are three areas guests/users and browse. These pages are Travel/Home.aspx, Menu/About/aspx, and Spotlight/Home.aspx. Each page also goes further in ie Page1 would give guests/users a list of current research being conducted and they can navigate further in by choosing the specific research project. The touchscreen also keeps a log of all the areas guests/users navigate to. I'm trying to filter this log so that I know which of the three main areas people visit the most. So far I can get my script to count and group ALL the logs like this:

Top 5 Destinations: 12 http://www..org/scraper.php?link=/Home.aspx
Top 5 Destinations: 5 http://www..org/scraper.php?link=/Menu/About.aspx
Top 5 Destinations: 1 http://www..org/scraper.php?link=/Posters/Home.aspx
Top 5 Destinations: 3 http://www..org/scraper.php?link=/ResearchAreas/Home.aspx
Top 5 Destinations: 1 http://www..org/scraper.php?link=/ResearchAreas/Nutrients.aspx
Top 5 Destinations: 1 http://www..org/scraper.php?link=/ResearchAreas/Nutrients/IdentificationOfNutrientSources.aspx
Top 5 Destinations: 1 http://www..org/scraper.php?link=/ResearchAreas/Nutrients/IdentificationOfNutrientSources/AtmosphericDeposition.aspx
Top 5 Destinations: 1 http://www..org/scraper.php?link=/ResearchAreas/Nutrients/IdentificationOfNutrientSources/AtmosphericDeposition/AtmosphericNutrientDeposition.aspx
Top 5 Destinations: 2 http://www..org/scraper.php?link=/ResearchAreas/RegionalMonitoring.aspx
Top 5 Destinations: 1 http://www..org/scraper.php?link=/ResearchAreas/RegionalMonitoring/BightRegionalMonitoring.aspx
Top 5 Destinations: 1 http://www..org/scraper.php?link=/Spotlight/Home.aspx
Top 5 Destinations: 1 http://www..org/scraper.php?link=/Staff/Home.aspx
Top 5 Destinations: 3 http://www..org/scraper.php?link=/Travel/Home.aspx
Top 5 Destinations: 1 http://www..org/scraper.php?link=/Travel/LosAngelesDepartures.aspx
Top 5 Destinations: 1 http://www..org/scraper.php?link=/Travel/Traffic.aspx

But as you can see it displays ALL the logs. I want it to group all the logs under Page1, PAge2, and Page 3 and give me a total count. This is my code so far.

> <?php
>     
>     #### mysql connection #####
>     $db = mysql_connect("_","guest","_");
>     mysql_select_db(networkr) or die("Couldn't select the database");
>     echo "<table>";
>     $query = "SELECT count(*),uri FROM logs GROUP BY uri";
>     $result = mysql_query($query) or die(mysql_error());
>     while($row = mysql_fetch_array($result)){
>       echo "Main Hits:  ". $row['0'] ."   ". $row['1'] ."";
>       echo "<br />";
>     }
>     echo "</table>";
>     ?>
  • 写回答

1条回答 默认 最新

  • drjv5597 2011-04-09 01:12
    关注

    Change your query to (1) sort by the count descending, and (2) limit to the top 3 (or as many as you'd like). Something like below

    $query = "SELECT count(*),uri FROM logs GROUP BY uri ORDER BY count(*) DESC LIMIT 3";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测