[Solved] Checking t...
 
Notifications
Clear all

[Solved] Checking to see if a story appears in a category (?)

1 Posts
1 Users
0 Reactions
1,361 Views
 Elle
(@jenny)
Posts: 594
Honorable Member
Topic starter
 

Hey,

Basics: Our archive is split up into three categories: Fiction (1), Art (2), Poetry (3), Fest (4), Fest 2 (5). (In reality, there are more categories, but it'd be more confusing to explain it all.)

In the profile/browse listings area, I am trying to split up "storiesby" by allowing members to filter out the categories. I copied the storiesby page, and duplicated it, editing it so this was appended in the where section: FIND_IN_SET('1', stories.catid) > 0 for the stories category, and so on. However, this doesn't work for stories multiple categories. So, something like this happens:

Filter: stories (9) — art (0) — poetry (1) — all (11)

Cases in point:

Story A has category 1,3. It DOESN'T appear in "stories", yet appears in "poetry".
Story B has category 1,4,5. It doesn't appear in "stories". Only all.

Example... (editing, so may not reflect error o_o)

I realise that the multiple category stories are essentially doing something like this; "FIND_IN_SET('1,2', '1,3,4,5,6')" and so it's looking for 1,2 in 1,3,4,5,6? (find_in_set documentation is confusing). Scary stuff.

I am not entirely sure what kind of query I am looking at to build, or how to even distinguish whether "the list of categories this story is in, contains an item on THIS list of categories". Oh, so confusing. 🙁

Help please?

ETA: Seems like I'm going to have to use arrays and implode() and separate FIND_IN_SET... is this correct? ;-;

Yessss. Arrays and imploding does the trick. I like how I can figure out the answer minutes after posting a help thread on here as opposed to spending hours on it prior and coming up with nothing. ._.


archive: dramione.org
site: accio.nu

Available for skin/mod commission! 🙂

 
Posted : 28/06/2010 10:22 pm
Share: