checkbox search
Posted: Fri Jul 18, 2008 5:51 am
Hi,
I want to do a search with checkbox, which would receive values from my database. I would be glad if someone told me what is wrong with this script.
index.php
search.php
I want to do a search with checkbox, which would receive values from my database. I would be glad if someone told me what is wrong with this script.
index.php
Code: Select all
<form name= "priorytet" action="search.php" method="post">
Your choice:
<input type="checkbox" name="priorytet[]" value="A">A
<input type="checkbox" name="priorytet[]" value="B">B
<input type="checkbox" name="priorytet[]" value="C">C
<input type="submit" value="Search!" />
</form>
Code: Select all
<?php
$db_name = "xxx";
$connection = @mysql_connect("xxx", "xxx", "xxx") or die("couldn't connect");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select db");
function skill_search($priorytet) {
if (!empty($priorytet)) {
$query = "SELECT DISTINCT priorytet
FROM treningi";
$query .= " AND (";
foreach ($treningi as $check) {
$query .= " priorytet = $check OR";
}
/* remove the final OR */
$query = substr($query, 0, -2);
$query .= ")";
$query=mysql_query("SELECT * FROM treningi");
while($row=mysql_fetch_array($array))
{
echo'<input name="priorytet" type="checkbox" value="' . $row['name'] . '" />
?>