PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Mikosww
Forum Newbie
Posts: 3 Joined: Fri Jul 18, 2008 5:38 am
Post
by Mikosww » 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
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>
search.php
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'] . '" />
?>
Last edited by
Mikosww on Fri Jul 18, 2008 7:52 am, edited 1 time in total.
Reviresco
Forum Contributor
Posts: 172 Joined: Tue Feb 19, 2008 4:18 pm
Location: Milwaukee
Post
by Reviresco » Fri Jul 18, 2008 7:33 am
You're missing the "WHERE" clause in the query.
Mikosww
Forum Newbie
Posts: 3 Joined: Fri Jul 18, 2008 5:38 am
Post
by Mikosww » Fri Jul 18, 2008 7:56 am
the error is "Parse error: syntax error, unexpected $end on line 33"
VladSun
DevNet Master
Posts: 4313 Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria
Post
by VladSun » Fri Jul 18, 2008 8:05 am
Mikosww wrote: the error is "Parse error: syntax error, unexpected $end on line 33"
Code: Select all
while($row=mysql_fetch_array($array))
{
echo'<input name="priorytet" type="checkbox" value="' . $row['name'] . '" />
?>
You are missing the
" ,
; and
}
There are 10 types of people in this world, those who understand binary and those who don't
Mikosww
Forum Newbie
Posts: 3 Joined: Fri Jul 18, 2008 5:38 am
Post
by Mikosww » Fri Jul 18, 2008 8:32 am
thanks for advices!
But there is still something wrong.
Parse error: syntax error, unexpected T_STRING on line 31.