Ik kwam een zoekscript tegen en probeer hem nu om te bouwen maar hij geeft steeds deze fout:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'template WHERE naam LIKE %% ORDER BY naam DESC LIMIT 0, 25' at l
Ik heb het gevoel dat hier een hele makkelijke oplossing aan zit maar ik kom er maar niet op ....
Dit is het script:
<?php
include("config.php");
?>
<html>
<head>
<title>zoek</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if($_SERVER['REQUEST_METHOD'] != 'POST') {
?>
<form action="zoeken.php" method="post">
<input type="text" name="trefwoord" value="trefwoord">
<input type="submit" name="submit" value="Zoeken!">
</form>
<?php
} else {
$trefwoord = $_POST['trefwoord'];
$sql = "SELECT * template WHERE naam LIKE %" .$trefwoord. "% ORDER BY naam DESC LIMIT 0, 25";
$res = mysql_query($sql) or die(mysql_error());
$num = mysql_num_rows($res);
if (empty($num)){
$num = "geen";
}
echo"Er zijn $num zoekresultaten gevonden.<br><br>\n";
while($row = mysql_fetch_object($res)){
?>
<a href="/index.php?id=<? echo $row->id ?>"><? echo $row->titel ?></a><br>
<br>
<?php
}
}
?>
</body>
</html>
Ziet iemand de oplossing?