English 中文(简体)
我如何做一个显示每次访问网页形象的访问台? 制作图像目录
原标题:How do I make a visit counter that displays an image for every visit the web page has had? Creating a collage of images
  • 时间:2012-04-14 19:36:01
  •  标签:
  • php
  • image

基本上,我正在建立一个数字艺术项目。

For this I am aiming to get a webpage to show how many visits its had by displaying an image for every visit. So basically every time someone visits or refreshes the web page a new image will appear; 50 visits = 50 images and so on. I want the images to be taken from a folder on the server at random. I have code for a basic visit counter, but it only works for sessions. I need to edit this code so that for every visit a random image appears. Apparently it should be fairly simple but I am very new to php and am still learning a lot.

这是我为访问反省而制定的守则:

session_start();
if(isset($_SESSION[ views ]))
  $_SESSION[ views ]=$_SESSION[ views ]+1;
else
  $_SESSION[ views ]=1
echo "Page views: ".$_SESSION[ views ];

Any help would be hugely appreciated :) Thanks for your time.

问题回答

你们需要利用数据库服务器或关键价值储存等解决办法,以某种方式坚持服务器上的访问次数。 例如,可在服务器上安装,然后在服务器上安装一个用户,如Predis

$redis = new PredisClient();
$redis->incr( views );

那么,如果你想要知道你有多少看法,你可以使用:

$views = $redis->get( views );




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签