Code: Selecteer alles
<?php
$cfg['db_user'] = ''; // De gebruikersnaam, dus.
$cfg['db_ww'] = ''; // Het wachtwoord.
$cfg['db_database'] = ''; // De database naam
$cfg['db_host'] = 'localhost'; // De database host naam
mysql_connect($cfg['db_host'], $cfg['db_user'], $cfg['db_ww']) or die (mysql_error());
mysql_select_db($cfg['db_database']) or die (mysql_error());
function strip_var($value)
{
$value = stripslashes($value);
$value = addslashes($value);
$value = strip_tags($value);
$value = htmlspecialchars($value);
$value = nl2br($value);
return $value;
}
$string = strip_var($_POST['string']);
/*
CREATE TABLE script_scripts
(
script_id INT NOT NULL AUTO_INCREMENT,
script_naam VARCHAR (40) NOT NULL,
script_auteur VARCHAR (40) NOT NULL,
script_categorie VARCHAR (40) NOT NULL,
script_uitleg TEXT NOT NULL,
script_code TEXT NOT NULL,
script_foto VARCHAR (100) NOT NULL,
PRIMARY KEY (script_id)
);
*/
?>
<form method="post" action="<?=$_SERVER['REQUEST_URI'];?>">
<table width="100%" id="zoeken" align="center">
<tr>
<td width="50%"><u>Zoekwoord:</u></td>
<td width="50%"><input type="text" name="string" size="30" <?php if(!Empty($string)) { echo "value=\"" .$string. "\""; } else { echo "value=\"vul hier je zoek ding in\" onclick=\"this.value=''\""; } ?> /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" value="Zoeken" /></td>
</tr>
</table>
</form>
<?php
if(IsSet($_POST['submit']))
{
if(!Empty($string) && $string != "vul hier je zoek ding in")
{
$select = mysql_query("SELECT * FROM script_scripts WHERE script_auteur LIKE '%" .$string. "%' OR script_naam LIKE '%" .$string. "%' OR script_uitleg LIKE '%" .$string. "%' OR script_code LIKE '%" .$string. "%'");
$count = mysql_num_rows($select);
if($count >= 1)
{
echo "<table width=\"100%\" id=\"zoekresultaat\" align=\"center\">";
echo "<tr><td>Keyword: <b>" .$string. "</b><br /><br /></td></tr>";
while($result = mysql_fetch_assoc($select))
{
// info inkorten indien nodig
if(strlen($result['script_uitleg']) > 400) $bresult = substr($result['script_uitleg'], 0, 350). " ...<br />>> <a href=\"LINKNAARARTIKELHIER\">bekijk script</a>";
else $bresult = $result['script_uitleg']. "<br /> <a href=\"http://www.herontdek.be/gent/horecazakengent/bekijk.php?id=" .$result['script_id']. "\"> lees alle reacties</a>";
echo "<tr><td>";
echo "<u>stad:</u> " .$result['script_auteur']. "<br />";
echo "<u>Reactie:</u> " .$bresult;
echo "<hr noshade size=0,5 /><br />";
echo "</td></tr>";
}
echo "</table>";
}
else
{
echo "Er werd niks gevonden ...";
}
}
}
else
{
echo "er is geen waarde opgegeven om naar te zoeken";
}
?>