Display a new image for every visitor

images php coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
User avatar
JordanMRichards
New php-forum User
New php-forum User
Posts: 81
Joined: Mon Apr 23, 2012 7:43 am
Contact:

Mon Apr 23, 2012 12:33 pm

You should store your page views in an sql database, that way you can retrieve them at any time.
I'm 14 and new to the forums I am a beginner in php also.

Just coded this bit up, it's untested, hope it helps ;)

Code: Select all

// images
$image1 = '50views.png';
$image2 = '100views.png';
$image3 = '150views.png';
$image4 = '200views.png';

//width and height per image
$eachwidth = 100px;
$eachheight = 100px;

$views = $_SESSION['views'];
if ($views>=50&&$views<100) {  // views for image 1
   echo "<img href='".$image1."' width='".$eachwdith."' height='".$eachheight."'></img>"
}else if ($views>=100&&$views<150) { // views for image 2
   echo "<img href='".$image2."' width='".$eachwdith."' height='".$eachheight."'></img>"
}else if ($views>=150&&$views<200) { // views for image 3
   echo "<img href='".$image3."' width='".$eachwdith."' height='".$eachheight."'></img>"
}else if ($views>=200&&$views<250) { // views for image 4
   echo "<img href='".$image4."' width='".$eachwdith."' height='".$eachheight."'></img>"
}
Hope this helps :)

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest