Training, Open Source computer languages

PerlPHPPythonMySQLhttpd / TomcatTclRubyJavaC and C++LinuxCSS

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
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
H999 - Additional PHP Material
H112 - PHP - Further Web Page and Network Handling
G902 - Well House Consultants - Web site techniques, utility and visibility

Back to
Flooding by Asda-s proposed new supermarket
Previous and next
or
Horse's mouth home
Forward to
Ongoing Image Copyright Issues, PHP and MySQL solutions

Some other Articles
Extracting information from a file of records
How not to write Perl?
Comments on proposed Asda Superstore for Melksham
Ongoing Image Copyright Issues, PHP and MySQL solutions
Script to present commonly used images - PHP
Flooding by Asda-s proposed new supermarket
Web page (http) error status 405
Java, sorting, ArrayList example, generics
Java - using super to call a method in the parent class
First Class Java. First step and moving forward.
1690 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 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).

© WELL HOUSE CONSULTANTS LTD., 2008: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho