Code: Select all
function search($search)
{
$arr = explode(' ',$search);
for($x=0; $x<sizeof($arr); $x++)
{
if($x==0) $search_string = 'fileinfo_a.answer like "%'.$arrї$x].'%"';
else
$search_string .= ' or fileinfo_a.answer like "%'.$arrї$x].'%"';
}
for($x=0; $x<sizeof($arr); $x++)
{
$search_string_comment .= ' or imagecomments.comments like "%'.$arrї$x].'%" or imagecomments.name like "%'.$arrї$x].'%" or imagecomments.email like "%'.$arrї$x].'%"';
}
$query = 'select fileinfo_a.id,fileinfo_a.photo_id from fileinfo_a, access, photofile, imagecomments where ('.$search_string.$search_string_comment.') and photofile.id = imagecomments.photo_id and fileinfo_a.photo_id = photofile.id and photofile.dir_id = access.dir_id and photofile.dir_id = photofile.dir_id and photofile.dir_id = access.dir_id and access.user_id = "'.$_SESSIONї'squitoid'].'" and access.r = "1" group by photo_id order by id asc';
$result = $this->query($query);
echo '<b><i>'.mysql_num_rows($result).'</i></b> Search Results from Search String <b><i>'.$_GETї'search'].'</i></b><hr>';
if(!mysql_num_rows($result)) echo 'No results found';
else echo '<table width="100%">';
while($myrow=mysql_fetch_array($result))
{
echo '<tr><td width="1" valign="top">'."\n";
echo $this->get_search_icon($myrowї'photo_id'])."\n";
echo '</td><td valign="top"></tr>'."\n";
}
echo '</table>'."\n";
}