문제

How to change text size of the link when people visits it? It is possible to change link text size when like 1000 visitors from a different IP address clicks on it? Currently i have a page with a lot of links and I need to separate them with different text size so users can see the most important links. ( It's like keywoard function).

Here is some examples:

enter image description here

enter image description here

도움이 되었습니까?

해결책

//SQL
CREATE TABLE keywords (
keyword_id int(11) NOT NULL AUTO_INCREMENT,
keyword varchar(200) NOT NULL,
keyword_count int(5) NOT NULL,
PRIMARY KEY(keyword_id)
)

//PHP
<?php
 //Write your select query here
 while($row = $result->fetch())
 {
    switch($row['count']) {
      //Add more cases if you want
       case 10:
          echo "<span class='row-count-10'><a href='lol.php?keywordid=".$row['keyword_id']."'>".$row['keyword']."</a></span>";
          break;
       default:
         echo "<span class='row-count-default'><a href='lol.php?keywordid=".$row['keyword_id']."'>".$row['keyword']."</a></span>";
    }
 }
?>


<?php
  //lol.php
  $keyword = $_GET['keywordid'];
  //INSERT STATEMENT
?>


//style.css
.row-count-default {
  font-size:10px;
}

.row-count-10 {
  font-size:12px;
}

다른 팁

enter image description here

  1. Parse visits on server side and pass metrics to view as JSON
  2. Adjust links on page load with javascript "for loop"

See it here: FIDDLE

Javascript:

var json = JSON.parse('{"link_1":2,"link_2":3,"link_3":7,"link_4":2}');
var base_size = 12; 
for (var link in json){
    document.getElementById(link).setAttribute("style","font-size:" + (json[link] * base_size) + "px;"); 
    //alert(json[link]);
}

HTML:

<a id="link_1">Link&nbsp;1</a>
<a id="link_2">Link&nbsp;2</a>
<a id="link_3">Link&nbsp;3</a>
<a id="link_4">Link&nbsp;4</a>
<a id="link_5">Link&nbsp;1</a>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top