i need some help with this query.
Basic info: I have a search-form named "sok" on index.php.
at page lsita2.php I make a variable called sok with the info from the searchfield at index.php. Now i'm trying to figure it out to include the variable in the query so it works as a search-function....
I put my code so you can tell me what i'm doin wrong...
<?
$sok = $_POST['sok'];
//connection to database
$con = mysql_connect("localhost", "username", "pass");
if(!$con) {
die('error:' . mysql_error());
}
//select database
mysql_select_db("database", $con);
//query
$result = mysql_query("SELECT * FROM a1 WHERE namn='$sok'");
//presentation of the lists
while($row = mysql_fetch_array($result))
{
echo $row['namn'];
echo "<br>";
}
mysql_close($con);
?>
Pleace help me out here....