Friday 17 July 2009

Text finalised on Photo Archive

The text on the homepage and the about-us for the photo archive has now been updated.

Bit of a fiddle to sort out the style sheets to make all the hyperlinks look consistent.

Thursday 2 July 2009

Sorting cars by year and registration with MySQL

Just published the updates to tjlobb.com

The sort order on the car listing page was tricky.

http://tjlobb.com/stocklist.php

The cars needed to be listed by type and within type by year, then registration and then price. The trick is that the registration is a mixture of letters and numbers (e.g. W, X, 05, 51) and simple MySQL "order desc" doesn't work.

Used the following nifty trick which might be useful if anyone else is doing a car sales webpage. Set up three fields regyear (int), regcode (varchar length 2) and price (float). Remembering to trim whitespace off regcode in case someone mistakingly enters some. Then MySQL does all the sorting.

SELECT ... ORDER BY regyear DESC, LENGTH(regcode) DESC, regcode DESC, price DESC

The LENGTH(regcode) ensures that 51 is higher in the list than 01 and both are higher than any letters.

Wednesday 20 May 2009

Tuesday 19 May 2009

photos.grampound.org.uk

After a little fiddling about with the ISP that manages grampound.org.uk the digital photo archive of the Heritage Centre in Grampound has now gone live.

http://photos.grampound.org.uk/

Wednesday 25 March 2009

Sending excel file to browser

Polished up the management screens and added an export facility (to Excel) for the gallery data. This is how to send an excel file to the browser.

<?php
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment;
filename=photoarchive.xls");
header("Pragma: no-cache");
header("Expires: 0");
// then send tab-delimited rows of your data
?>

Tag cloud formula

Modified the tag cloud for photo categories using a neat formula adapted from that found at http://r2soft.blogspot.com/2007/12/how-to-create-tag-cloud-with-formula.html

Choose a $lower_threshold then select tag counts having count of $lower_threshold or more. Find the highest tag count and define largest and smallest font size.
$cloudnumber=round(( (($this_tag_count-$lower_threshold) *
($largest_font_size-$smallest_font_size)) /
($most_popular_tag_count-$lower_threshold) )
+ $smallest_font_size);
if ($cloudnumber<0) { $cloudnumber=0; }

I put the clouds into 6 discrete buckets defined by CSS - ('cloud'.$cloudnumber) cloud0, cloud1, cloud2 etc. then modify the characteristics of the buckets. Could make it a more continuous variation in font size using a range of 75% to 300% which seems popular but I like the look of the fixed buckets generated by the $cloudnumber.

Altering the $lower_threshold will help to limit the number of tags on the photographs screen. Probably, in due course, add a 'more' link which will go to an alternative screen where the $lower_threshold is set to 1.

Monday 23 March 2009

Grampound with Creed Photo Archive

Need to sort out the domain to publish and it is launched.

This has been a challenging project to design an 'easy-to-use' photo archive that is database driven, managed by several individuals with various levels of IT skills, and have a mirror version running from a PC that does not have internet access.

Many thanks to XAMPP, Mootools, Highslide JS and freecsstemplates.org.