Hi I have made a mysql database. And a html file to search in the database. But he doesn't display any results on the screen. He works only when there is no data matching in the databse arcording to your search. Then he gives a message like this: "There is no data found!!! Try again with another search".
What is the problem?? The code is displayed bellow.
<head>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
function controleerForm() {
$errormessage = "";
if (document.zoeken.zoekopdracht.value == " ") $errormessage += "\n U heeft geen trefwoord opgegeven, voer alsnog een trefwoord in.";
if ($errormessage != "") {
alert ($errormessage);
return false;
} else {
return true;
}
}
</SCRIPT>
<?
mysql_connect('mysql_server', 'mysql_user') or die ("Fout");
?>
<i>- Search in the database...</i><BR><BR>
<Br>
<Br>
<Br>
<Br>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="490" height="168">
<tr>
<td valign="top" align="center">
<p align="center"><b><u> Type a search statement and press on the button.</u></b>
</tr>
</center>
<tr>
<td width="50%" valign="top">
<form action="zoek.php" name="zoeken" onSubmit="return controleerForm();">
<p align="center"><input type="hidden" name="kolom_naam" value="bo_naam" checked>
<input type="text" name="zoekopdracht" value="<? echo "$zoekopdracht"; ?>">
</td>
</tr>
<tr>
<td width="100%" valign="top">
<p align="center"><input type="submit" name="submit" value="search"><br>
</td>
</tr>
</table>
</form>
</div>
<?
if ($submit == "search")
{
if ($kolom_naam == "bo_naam")
{
/ Er is op de knop "zoek" gedrukt /
$zoekstring = '%'.$zoekopdracht.'%'; / plak strings aan elkaar /
$result = mysql(potplanten, "SELECT FROM zoek WHERE $kolom_naam like '$zoekstring' ORDER BY vbn_code");
/ kolom_naam is trefwoorden */
}
$fout = mysql_error();
if ($fout == 0)
{
/ als fout == 0 dan, is alles goed gegaan /
$aantal_rijen = mysql_num_rows($result);
if ($aantal_rijen == 0) {
echo "Uw zoekopdracht heeft geen resultaat opgeleverd.<Br>
U mag ook alleen de eerste letters invoeren, bijv. bloe in plaats van bloemstukken.<Br>
Zo vergroot u de trefkans.<Br>
<Br>
<Br><a href='mailto:database@bestinfo.nl'><br>Zit uw bedrijf of instelling er niet bij, of bevat deze een fout,<Br>
wij passen onze database geheel gratis voor u aan.<Br>
ALLEEN BEDRIJVEN EN INSTELLINGEN UIT BEST!</a>";
} /* einde aantal rijen == 0 */
else
{
echo "<table border='2' cellpadding='0' cellspacing='0' width='100%'>";
for ($i=1; $i<mysql_num_rows($result); $i++)
{
$row = mysql_fetch_array($result);
echo "<tr>";
echo "<td width='34%'>VBN code:<br>$row[vbn_code]</td>";
echo "<td width='33%'>Nederlandse naam:<br>$row[nl_naam]</td>";
echo "<td width='33%'>De icoons:<br>$row[icoons]</td>";
echo "</tr>";
echo "<tr>";
echo "<td width='100%' colspan='3'>Botanische naam:<br>$row[bo_naam]</td>";
echo "</tr>";
echo "<tr>";
echo "<td width='100%' colspan='3'>Foto:<br>$row[foto]</td>";
echo "</tr>";
echo "<tr>";
echo "<td width='100%' colspan='3'>Verzorgingswijze:<br>$row[verzorging]</td>";
echo "</tr>";
echo "<br>";
}
echo "</table>";
}
}
/* einde aantal rijen > 0 */
/ einde $fout == 0 /
else {
echo "Er is iets fout gegaan bij het communiceren met de database";
#query failed, print debug info
echo "SQL ERROR: ".mysql_error();
echo "<br>";
};
/ Einde zoek /
}
?>
</body>