Search Function with PHP and mySQL
Posted: Sat Sep 03, 2005 10:55 pm
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.
But I don't get a result. All I get is a blank page. Why is that?
feyd | Please use
Code: Select all
<form method="POST" action="sok.php">
<input type="text" size="30" name="query" class="formularinput"><br />
<input type="submit" name="sok" class="formularinput" value="Sok">
</form>
<?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(isset($_POST['sok'])) {
$result = mysql_query("SELECT * FROM sotd WHERE Grupp LIKE '%{$_POST['query']}%'");
while($r = mysql_fetch_assoc($result)) {
echo "<p>{$r['Grupp']}<br />{$r['lat']}<br />{$r['spelare']}</p>";
// echo $row ['grupp'];
// echo $row ['lat'];
// echo $row ['spelare'];
}
}
?>But I don't get a result. All I get is a blank page. Why is that?
feyd | Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]