<?php
if (isset($search))
{
$search = $_POST['search'];
$sql = "SELECT * FROM `logs` WHERE station LIKE \"%$search%\" OR url LIKE \"%$search%\" ORDER BY id DESC";
$result = mysql_query($sql) or die ("Couldn't execute query 1.");
$found = mysql_num_rows($result);
//$row = mysql_fetch_array($result);
//$url = $row['url'];
$url_times = array();
foreach($found as $url)
{
if( !in_array($result, $search_results_array) )
{
//do yo shit
$tmp = array($result);
$search_results_array = array_merge($search_results_array,$tmp);
$found_num++;
}
if( in_array($result, $search_results_array) )
{
if( !array_key_exists($result, $url_times) )
{
$tmp = array($result => 1);
$url_times = array_merge($url_times,$tmp);
}
else
{
$url_times[$result] = $url_times[$result] + 1;
}
}
}
echo "Found <b>".$found_num."</b> urls containing the word <b>".$search."</b><br>";
foreach($url_times as $site => $times)
{
echo "<i>".$site."</i> was found a total of <i>".$times."</i> times";
}
echo "</i> was found a total of <i>".$times."</i> times";
}
?>
basically it will search the database for a url, show the url only once, and then show how many times that url was found.