', '-', $search); //replace foriden filename charcater by -
$search = str_replace('(', '-', $search); //replace foriden filename charcater by -
$search = str_replace(')', '-', $search); //replace foriden filename charcater by -
$search = str_replace('[', '-', $search); //replace foriden filename charcater by -
$search = str_replace(']', '-', $search); //replace foriden filename charcater by -
$search = str_replace('=', '-', $search); //replace foriden filename charcater by -
$search = str_replace('+', '-', $search); //replace foriden filename charcater by -
$search = str_replace('"', '-', $search); //replace foriden filename charcater by -
$search = str_replace(',', '-', $search); //replace foriden filename charcater by -
$search = str_replace('.', '-', $search); //replace foriden filename charcater by -
$search = str_replace(':', '-', $search); //replace foriden filename charcater by -
$search = str_replace(';', '-', $search); //replace foriden filename charcater by -
$character = "'";
$search = str_replace($character, "-", $search); //replace foriden filename charcater by -
$character = "\ ";
$character = trim($character);
$search = str_replace($character, "-", $search); //replace foriden filename charcater by -
$search = str_replace('-', ' ', $search);
/* */
}else
$search = '';
$search = mysql_escape_string(strip_tags(trim($search)));
$_SESSION[search] = $search;
//2. define a function to store search term
function store_search_term($term)
{
global $link;
$term = mysql_escape_string(strip_tags(trim($term)));
$date = time();
/*
$result = mysql_query("insert into search_terms(search, last_update)
values('$term', '$date')", $link); */
$result = mysql_query("insert into searchterms(term)
values('$term')", $link);
}
//3. define function to display search results
function writeContents($Num)
{
global $link;
//start of multipage insert 1
// 1. how many rows to show per page
$rowsPerPage = 12;
//$rowsPerPage = $_SESSION[rowsPerPage];
// 2. by default we show first page
//$pageNum = 1;
$pageNum = $Num;
// 3. if $_GET['page'] passed from previous URL, use it as page number
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}
// 4. counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
//end of multipage insert 1
//incorporating the seach variables into the select query:
//$user_id = $_SESSION['user_id'];
$user_id = 1;
$search = $_SESSION[search];
$query = "SELECT * ";
$query .= "FROM directory WHERE ";
$query .= " org_name LIKE '%$search%' ";
/*
$match = explode(" ", $search);
foreach($match as $key => $value)
{
if(strlen($value) > 1 and $value != 'services' )
{
//search
//echo "key $key has value $value
";
$query .= " org_name LIKE '%{$value}%' ";
//$query .= " OR class_ctg_alt LIKE '%{$value}%' ";
$query .= " OR ";
}
}
if(strlen($match[0]) > 1 and $value != 'services' )
$query .= " org_name LIKE '%{$match[0]}%' ";
else
$query .= " org_name LIKE '%zulu%' ";
$query .= " class_ctg_name LIKE '%{$search}%'";
$query .= " OR class_ctg_alt LIKE '%{$search}%' ";
*/
$query .= " LIMIT $offset, $rowsPerPage "; //start of multipage insert 2
$result = mysql_query($query, $link);
if(!result)
die("getIDcontents fatal error : ".mysql_error);
//$result = getRecipes($user_row[user_id]); //if calling outside function
if ($result){
$numrows = mysql_num_rows($result);
$_SESSION[numrowws] = $numrows;
}
if ($result) $numcols = mysql_num_fields($result);
if (!$result)
{
echo "
Search result: No Listings.
"; return; } else{ if($numrows > 0) { echo '
Zimbabwe Business Directory
$maximum) $maximum = $num_results; //else //$maximum = 1; $terms[] = array('term' => $search, 'counter' => $num_results); } // shuffle terms unless you want to retain the order of highest to lowest //shuffle($terms); // start the output to the page echo " Popular Searches\n";
/*
// $terms is the array
arsort($terms);
//$max_size = 32; // max font size in pixels
//$min_size = 12; // min font size in pixels
$max_size = 20; // max font size in pixels
$min_size = 10; // min font size in pixels
// largest and smallest array values
//$max_qty = max(array_values($terms));
//$min_qty = min(array_values($terms));
$max_qty = $maximum;
$min_qty = 1;
// find the range of values
$spread = $max_qty - $min_qty;
if ($spread == 0)
{ // we don't want to divide by zero
$spread = 1;
}
// set the font-size increment
$step = ($max_size - $min_size) / ($spread);
// loop through the tag array
//foreach ($terms as $key => $val)
foreach ($terms as $k) // start looping through the tags
{
// calculate font-size
// find the $value in excess of $min_qty
// multiply by the font-size increment ($size)
// and add the $min_size set above
if($spread < 10)
$size = rand($min_size, $max_size);
else
$size = round($min_size + (($value - $min_qty) * $step));
// output this term
echo "" . $k['term'] . "\n ";
}
*/
foreach ($terms as $k) // start looping through the tags
{
// determine the popularity of this term as a percentage
$percent = floor(($k['counter'] / $maximum) * 100);
// determine the class for this term based on the percentage
if ($percent <20)
{
$class = 'smallest';
} elseif ($percent>= 20 and $percent <40) {
$class = 'small';
} elseif ($percent>= 40 and $percent <60) {
$class = 'medium';
} elseif ($percent>= 60 and $percent <80) {
$class = 'large';
} else {
$class = 'largest';
}
// output this term
echo "" . $k['term'] . "\n ";
}
// close the output
echo "
All directory listings and classified ads are added and edited by visitors to this site. If you do not find your organisation please login and add it too. Watch this space for classifieds Ads soon. |
The LiveSearch facility will work if you have enabled JavaScript in your internet browser. Otherwise use the submit button to search. "; include( "../my_inc".DIRECTORY_SEPARATOR."hit_stats_public.inc"); echo ""; ?> |
|