Most popular value for tag "$tag_html"\n"; } else { echo "

Least popular value for tag "$tag_html"

\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"); $getcomment =& $conn->prepare("SELECT id, comment FROM tagcomments WHERE tag=? ORDER BY score DESC LIMIT 1"); $result =& $conn->execute($getcomment, $tag); if (DB::isError($result)) { echo "Sorry, can't retrieve comments for this tag"; } else if ($result->numRows() > 0) { echo "

Comment

\n"; $row =& $result->fetchRow(); $id = $row[0]; echo "
\n"; echo htmlspecialchars($row[1], ENT_NOQUOTES)."
\n"; echo "Vote up \n"; echo "Vote down \n"; echo "Edit \n"; echo "
\n"; } else { echo "Write a comment for this tag"; } $result->free(); echo "

Stats

\n"; $getcount =& $conn->prepare("SELECT tag, value, count FROM tagpairs WHERE tag = ? ORDER BY count $dir LIMIT $limit"); $result =& $conn->execute($getcount, $tag); 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"; } printf('', $style, displayTag($row[0]), displayTag($row[1]), displayNum($row[2])); if($dir == "ASC") { $getsuggestion =& $conn->prepare("SELECT value, count FROM tagpairs WHERE tag = ? AND SOUNDEX(value) = SOUNDEX(?) AND value <> ? ORDER BY count DESC LIMIT 1"); $result2 =& $conn->execute($getsuggestion, array($row[0], $row[1], $row[1])); 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 "
tagvalueusessuggestion
%2$s%3$s%4$s%1$s (%2$s) 
\n"; $result->free(); $getfurther =& $conn->prepare("SELECT id, comment FROM tagcomments WHERE tag=? ORDER BY score DESC LIMIT 11"); $result =& $conn->execute($getfurther, $tag); if (DB::isError($result)) { echo "Sorry, can't retrieve further comments for this tag"; } else if ($result->numRows() > 0) { echo "

Further Comment

\n"; $row =& $result->fetchRow(); // Discard first one while($row =& $result->fetchRow()) { $id = $row[0]; echo "
\n"; echo htmlspecialchars($row[1], ENT_NOQUOTES)."
\n"; echo "Vote up \n"; echo "Vote down \n"; echo "Edit \n"; echo "
\n"; echo "
\n"; } } echo "View all comments
\n"; echo "

\n"; $result->free(); $conn->disconnect(); if($dir == "DESC") { echo "Rare values\n"; } else { echo "Popular values\n"; } $limit += 25; if($dir == "DESC") { echo "More values\n"; } else { echo "More values\n"; } echo "Back to index page\n"; ?>