Popular tags\n"; } else { echo "

Least popular tags

\n"; } $dsn = "mysqli://$user:$passwd@$host/$db"; $conn =& DB::connect($dsn); if (DB::isError($conn)) { die ("Cannot connect: " . $conn->getMessage() . "\n"); } $conn->query("SET NAMES utf8"); $result =& $conn->query("SELECT tag, uses FROM tags ORDER BY uses $dir LIMIT $limit"); if (DB::isError($result)) { die ("SELECT failed: " . $result->getMessage() . "\n"); } echo "\n"; echo ""; if($dir == "ASC") { echo ""; } echo "\n"; $i = 1; while ($row =& $result->fetchRow()) { if($i % 2) { $style="odd"; } else { $style="even"; } $rank = get_tag_rank($conn, $row[1]); printf('', $style, $row[0], displayNum($row[1]), $rank, displayTag($row[0])); if($dir == "ASC") { $getsuggestion =& $conn->prepare("SELECT tag, uses FROM tags WHERE SOUNDEX(tag) = SOUNDEX(?) AND tag <> ?ORDER BY uses DESC LIMIT 1"); $result2 =& $conn->execute($getsuggestion, array($row[0], $row[0])); if (!DB::isError($result2) && $result2->numRows() == 1) { $row2 =& $result2->fetchRow(); if(($row2[0] != "") && ($row2[1] > 10)) { printf('', displayTag($row2[0]), displayNum($row2[1])); } else { echo ""; } $result2->free(); } } echo "\n"; $i++; } echo "
#tagusessuggestion
%4$s%5$s%3$s%1$s (%2$s) 
\n"; $result->free(); $conn->disconnect(); if($dir == "DESC") { echo "Rare tags\n"; } else { echo "Popular tags\n"; } $limit += 25; if($dir == "DESC") { echo "More tags\n"; } else { echo "More tags\n"; } echo "Back to index page\n"; ?>