<?php
/**
* @version 2.1.1
* @package kwalbum
* @since 2.0 2008-08-20
*/
require_once pathinfo(__FILE__, PATHINFO_DIRNAME).'/../include/DBConnection.php';
$DB = new DBConnection();
$limit = 5;
if (empty($P['loc']))
exit;
$tag = trim($DB->FilterString($P['loc']));
if (empty($tag))
exit;
$where = '';
$found = false;
echo '<ul>';
$query = 'SELECT Location FROM '.LOCATION_TABLE .
" WHERE Location = '$tag' " .
"LIMIT $limit";
$result1 = $DB->Query($query);
if (0 < $result1->num_rows)
{
$row = $result1->fetch_array();
$where .= " AND Location != '$row[0]'";
$found = true;
echo '<li><b><big>'.$row[0].'</big></b></li>';
}
$query = 'SELECT Location FROM '.LOCATION_TABLE .
" WHERE Location LIKE '$tag%' " .$where .
"ORDER BY LocationCount DESC " .
"LIMIT $limit";
$result1 = $DB->Query($query);
if (0 < $result1->num_rows)
while ($row = $result1->fetch_array())
{
$where .= " AND Location != '$row[0]'";
$len = strlen($tag);
echo '<li><b><big>'.
substr($row[0], 0, $len).'</big></b>'.
substr($row[0], $len).'</li>';
}
if (!$found)
echo "<li><b><big>$tag</big></b></li>";
$limit -= $result1->num_rows;
$query = 'SELECT Location FROM '.LOCATION_TABLE .
" WHERE Location LIKE '%$tag%' " .$where .
"ORDER BY LocationCount DESC " .
"LIMIT $limit";
$result2 = $DB->Query($query);
if (0 < $result2->num_rows)
while ($row = $result2->fetch_array())
{
$pos1 = stripos($row[0], $tag);
$len = strlen($tag);
$pos2 = $pos1+$len;
echo "<li>".substr($row[0], 0, $pos1).'<b><big>'.
substr($row[0], $pos1, $len).'</big></b>'.
substr($row[0], $pos2).'</li>';
}
?>
</ul>