It's always better to tweak the SQL because it is more flexible.
I think you may need to put array_unique here
PHP Code:
$fieldname=mysql_field_name($data,$num);
$results=mysql_query("SELECT * FROM table WHERE ($fieldname) LIKE '%$search%'");
while($r=mysql_fetch_array($results))
{
[b]$r = array_unique($r);[/b]
$row[]=array_merge($r, $row);
}
More help here
The code may not work but you cannot use array_unique on the final array as it is a nested array. You need to use on each array within the containing array. You can do it outside too
PHP Code:
foreach ($output as $row)
{
$row = array_unique($row);
}
Note: this works only for PHP 5 and above where foreach returns a reference. If not, you have to do a normal loop
PHP Code:
for ($i = 0; $i < count($output); $i++)
{
$output[i] = array_unique($output[i]);
}
Bookmarks