the code i've used is as follows - note I'm not a php coder *at all* so there are probably some awful code things in there. I didn't care too much about the speed (I do a count of each keyword within the loop so there are a lot of database lookups) but as I don't have many keywords *I* don't really care but if someone else wants to improve that would be great.
<?php
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery 1.2.0 //
// ------------------------------------------------------------------------- //
// Copyright (C) 2002,2003 Gregory DEMAR <gdemar@wanadoo.fr> //
// http://www.chezgreg.net/coppermine/ //
// ------------------------------------------------------------------------- //
// Updated by the Coppermine Dev Team //
// (http://coppermine.sf.net/team/) //
// see /docs/credits.html for details //
// ------------------------------------------------------------------------- //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// ------------------------------------------------------------------------- //
define('IN_COPPERMINE', true);
define('SEARCH_PHP', true);
require('include/init.inc.php');
pageheader($lang_search_php[0]);
starttable(500, $lang_search_php[0]);
echo <<< EOT
<tr><td>Please enter a keyword:</td></tr>
<tr>
<form method="get" action="thumbnails.php">
<input type="hidden" name="album" value="search">
<input type="hidden" name="type" value="full">
<td class="tableb" align="center" height="60">
<input type="input" style="width: 90%" name="search" maxlength="255" value="" class="textinput">
</td>
</tr>
<tr>
<td colspan="8" align="center" class="tablef">
<input type="submit" value="{$lang_search_php[0]}" class="button">
</td>
</form>
</tr>
EOT;
endtable();
echo "<br><br>" ;
// Select all keywords
starttable("80%", "All keywords in the database", 1);
$result = mysql_query("select keywords from {$CONFIG['TABLE_PICTURES']}");
if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_errors['non_exist_ap']);
// Find unique keywords
$keywords_array = array();
while (list($keywords) = mysql_fetch_row($result)) {
$array = explode(" ",$keywords);
foreach($array as $word)
{
if (!in_array($word,$keywords_array)) $keywords_array[] = $word;
}
}
sort($keywords_array);
$count = count($keywords_array);
// Result to table
echo "<tr><td>" ;
for ($i = 0; $i < $count; $i++) {
//get count of each word.
$keywordcount= mysql_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} where keywords like '%$keywords_array[$i]%'");
//First divide the number of times a keyword appears by 4, then round down to the nearest whole number. Add 10 to this number to get the pixel size and create a style for this magic number.
//I couldn't work out how to do a select count * in sql and return data that works hence the my_sql_num_rows instead
echo "<a href=\"thumbnails.php?album=search&search=$keywords_array[$i]\" style=\"font-size: " . floor(10+(mysql_num_rows($keywordcount)/4)) . "px;\">$keywords_array[$i]</a></font> ";
}
echo "</td></tr>" ;
endtable();
echo
pagefooter();
ob_end_flush();
?>