Problem search multiple categories

Post Reply
ethanb
Posts: 6
Joined: Thu Jul 09, 2009 2:31 pm

Problem search multiple categories

Post by ethanb »

I don't see a reason why the Genre search list couldn't be checkboxes instead of radio buttons - that way you could search for, say, Joseki and Fuseki problems instead of just one or the other.
nait
Posts: 1
Joined: Wed Apr 08, 2009 1:24 pm

Re: Problem search multiple categories

Post by nait »

Very much so :!: :!:

In status, this should also enable the option "tried" AND "not solved" which I would find very natural to use a lot.
In status, some combinations would make little sense, though (e.g. tried AND not tried). So, here, the common options could as well be radio buttons still, but with all the combinations that make sense:

- Any
- Tried and never failed / always solved
- Tried and failed as well as solved
- Tried and never solved / always failed
- Not tried
- Tried or not tried, but never solved

As it is, "not solved" means the latter, but this is not very clear when you read it.
tails
Posts: 90
Joined: Thu Oct 23, 2008 12:10 pm

Re: Problem search multiple categories

Post by tails »

Hi. As an easy solution, I have added "Tried but unsolved" status.
ethanb
Posts: 6
Joined: Thu Jul 09, 2009 2:31 pm

Re: Problem search multiple categories

Post by ethanb »

Er, sorry, but this is not a solution at all. (EDIT: oh, I see - nait suggested a new radio button for the solved status separate from the checkbox idea. In any case, the pseudocode below should help with the checkbox genre implementation.)

Rather than a new flag, it should be combinations of flags that are allowed. The site is in PHP, and I assume an SQL backend, so it would be something like:

(on pages)

Code: Select all

<input type="checkbox" name="genre[]" value="joseki">Joseki
<input type="checkbox" name="genre[]" value="fuseki">Fuseki
<input type="checkbox" name="genre[]" value="lifendeath">Life and Death
<input type="checkbox" name="genre[]" value="tesuji">Tesuji
etc...
and in the PHP:

Code: Select all

$sql = "SELECT * from problems ";
if ($_POST["genre"])
{
  $sql += "WHERE ";
  for ($i = 0; $i < sizeof($_POST["genre"]); $i++)
  {
    $sql += "genre = '" + $_POST["genre"][$i] + "'";
    if ($i < sizeof($_POST["genre"]))
      $sql += " OR ";
  }
}
$sql += ";";
Note that my PHP + HTML is a bit rusty, so there may be errors, but this is at least very close.
tails
Posts: 90
Joined: Thu Oct 23, 2008 12:10 pm

Re: Problem search multiple categories

Post by tails »

Yes, that's technically possible.

But I think there is a trade-off. Assume all the boxes are checked inintially. When you want joseki problems, you'll have to turn off all the boxes except joseki one. I think some people may feel it annoying.

I (as a mere maintener) can't decide which is better, so I must respect the fact that adum chose radio buttons. That's why I didn't implement your idea, sorry.
User avatar
adum
Site Admin
Posts: 422
Joined: Tue Sep 30, 2008 5:09 pm

Re: Problem search multiple categories

Post by adum »

i agree that checkboxes would probably be superior... especially for the tried/solved type stuff. it's probably radio buttons for the simple reason that i didn't think the design through carefully when i made it originally.
tails
Posts: 90
Joined: Thu Oct 23, 2008 12:10 pm

Re: Problem search multiple categories

Post by tails »

Aye aye, sir :-)

Here is a candidate page that uses checkboxs for problem conditions:
http://www.goproblems.com/problems-test1.php3

Please comment if you have any suggestions. > all
User avatar
adum
Site Admin
Posts: 422
Joined: Tue Sep 30, 2008 5:09 pm

Re: Problem search multiple categories

Post by adum »

looks nice to me... what do others think?
tails
Posts: 90
Joined: Thu Oct 23, 2008 12:10 pm

Re: Problem search multiple categories

Post by tails »

Okay, I've replaced the page. (The URL above is no longer available.)

The old page will be available for a while at:
http://www.goproblems.com/problems-old.php3
ethanb
Posts: 6
Joined: Thu Jul 09, 2009 2:31 pm

Re: Problem search multiple categories

Post by ethanb »

Awesome! Thanks!
Post Reply