replace('zoekwoord',htmlspecialchars($_GET['zoek_op']));
$template->replace('number_of_results',mysql_result(mysql_query("SELECT count(1) FROM fotos WHERE MATCH (titel,omschrijving,tags) AGAINST ('".mysql_real_escape_string($_GET['zoek_op'],$connectie)."' IN BOOLEAN MODE) LIMIT 0,1",$connectie),0,0));
$pagina = $_GET['pagina']*10;
if ($_GET['orderby'] == 1)
{
$orderby = "f.id";
}elseif ($_GET['orderby'] == 2)
{
$orderby = "MATCH (f.titel,f.omschrijving,f.tags) AGAINST ('".mysql_real_escape_string($_GET['zoek_op'],$connectie)."' IN BOOLEAN MODE)";
}elseif ($_GET['orderby'] == 3)
{
$orderby = "f.views";
}elseif (!isset($_GET['orderby']))
{
$orderby = "f.id";
}
$query = mysql_query("
SELECT
f.bestandsnaam,
u.username,
f.toegevoegd,
f.tags,
f.bestand
FROM
fotos AS f,
filesystem AS g,
users AS u
WHERE
MATCH (f.titel,f.omschrijving,f.tags) AGAINST ('".mysql_real_escape_string($_GET['zoek_op'],$connectie)."' IN BOOLEAN MODE)
AND
f.id=g.foto
AND
u.id=g.uid
ORDER BY ".$orerby." DESC
LIMIT ".$pagina.",10",$connectie);
$i = 1;
$temphtml = "";
$template2 = new template();
$template2->load("zoekresultaten_resultaat.html");
$j = 0;
while ($array = mysql_fetch_array($query))
{
if ($i == 3)
{
$temphtml .= $template2->return_html();
$template2 = new template();
$template2->load("zoekresultaten_resultaat.html");
$i = 1;
$j++;
}
$template2->replace('foto_title'.$i,$array[0]);
$template2->replace('foto_screenname'.$i,$array[1]);
$template2->replace('foto_upload_date'.$i,$array[2]);
$tags = explode(",",$array[3]);
$taghtml = '';
foreach ($tags AS $tag)
{
$taghtml .= ''.trim(htmlspecialchars($tag)).' ';
}
$template2->replace('tags'.$i,$taghtml);
$template2->replace('foto_thumb'.$i,'http://thumbs.imgme.nl/'.$array[4]);
$template2->replace('last',$j);
$i++;
}
if ($i == 2)
{
$template2->replace('foto_screenname2','dit vak deleten');
$template->replace('javascriptje','');
}else{
$template->replace('javascriptje','');
}
$temphtml .= $template2->return_html();
$template->replace('resultaten',$temphtml);
$template->parse();
?>