|
Script to present commonly used images - PHP
"What are the most popular pages in your picture library, and where are they used from?" An interesting question and I could analyze raw web logs to find out the answers. However, most of our images are managed by a script that retains extra information such as an image title, and uses are logged ... so a simple PHP script will do the job admirably!
<?php
$most = fopen("../picfeed.txt","r");
while ($line = fgets($most,4096)) {
$parts = explode(" ",$line);
$counter[$parts[0]]++;
}
arsort($counter);
$v = 0;
foreach (array_keys($counter) as $pname) {
$html .= "$v: <img src=http://www.wellho.net/pix/$pname.jpg><br />";
if (++$v > 10) break;
}
?>
<html>
<head><title>Our most viewed pictures</title></head>
<body><h1>Most Viewed Pictures</h1>
Here are our most viewed pictures:<br>
<?= $html ?>
</body></html>
If you want to see our most popular images - dynamically - there's a link to that script running here. There's also an alternative version showing counts, tables of most popular referrers, and which allows you to page through the pictures page by page. You can run that alternative script here or here to show only images loaded by references from other sites and you can see the source code here. Passwords changed, of course.
Oh - <advert> I'll teach you how to do this on our PHP course! </advert> (written 2008-01-13 15:20:33)
Associated topics are indexed under G902 - Well House Consultants - Web site techniques, utility and visibilityH112 - PHP - Further Web Page and Network HandlingH999 - Additional PHP Material
Some other Articles
Extracting information from a file of recordsHow not to write Perl?Comments on proposed Asda Superstore for MelkshamOngoing Image Copyright Issues, PHP and MySQL solutionsScript to present commonly used images - PHPFlooding by Asda-s proposed new supermarketWeb page (http) error status 405Java, sorting, ArrayList example, genericsJava - using super to call a method in the parent classFirst Class Java. First step and moving forward.
|
2258 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46 at 50 posts per page
This is a page archived from The Horse's Mouth at
http://www.wellho.net/horse/ -
the diary and writings of Graham Ellis.
Every attempt was made to provide current information at the time the
page was written, but things do move forward in our business - new software
releases, price changes, new techniques. Please check back via
our main site for current courses,
prices, versions, etc - any mention of a price in "The Horse's Mouth"
cannot be taken as an offer to supply at that price.
Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).
|
|