Here is the deal. I am planning to add a search function on my website for user to use in order to serach fo info in my database of bands and so forth.
Ok now I'm finally done with the code. Everything works just great.
So I'm pasting it here in case anyone else needs a code like this.
ofcoiurse change the code to your personal needs.
<?php
$username = "user";
$password = "pass";
$hostname = "localhost";
$db = "sotdtest";
$dbh = mysql_connect($hostname, $username, $password) or die(mysql_error());
$selected = mysql_select_db($db) or die(mysql_error());
if (!empty($_GET['query'])) {
$sql = "
SELECT * FROM sotd
WHERE Grupp LIKE '%{$_GET['query']}%' OR lat LIKE '%{$_GET['query']}%' OR
spelare LIKE '%{$_GET['query']}%'
ORDER BY Grupp, Lat, Spelare
";
$result = mysql_query($sql) or die("SQL: $sql <br>".mysql_error());
if (mysql_num_rows($result) > 0)
while($r = mysql_fetch_assoc($result))
echo "<p>{$r['Grupp']}<br />{$r['Lat']}<br />{$r['Spelare']}</p>";
else
echo "Nothing found on that query \"{$_GET['query']}\"";
}
else
echo "No search word used";
?>