Copy link to clipboard
Copied
I'm building a list for a menu system using php a database table called content and the standard repeat region behavior. I've done this many times before. My "contentRS" table looks like this:
id | link | class |
---|---|---|
1 | page_01 | red |
2 | page_02 | green |
3 | page_03 | red |
4 | page_04 | blue |
5 | page_05 | green |
6 | page_06 | red |
I want to generate a list but only show that list when the class = red. Hiding the list when the class does not equal red is easy. Limiting the list to only records with a class = red is the problem.
I've set up the following code:
<?php do { ?>
<?php if ($row_contentRS['class'] == "red") {
echo "<li>" .$row_contentRS['class'] . "</li>";
} ?>
<?php } while ($row_contentRS = mysql_fetch_assoc($row_contentRS)); ?>
The first part works just fine. The repeat region, however, repeats all of the links so I end up with this: (as expected)
What I want is this:
I can modify the contentRS by editing the query so the RS only reveals the records with a class of "red" by modifying the record set with the following statement:
SELECT *
FROM content
WHERE class = 'red'
This solves my problem, except that I have 90 different class variables now and I will end up with a bunch more. I don't want to have to create a different record set for each. I already know how to reuse the repeat region. What I'd like to do is figure a way embed the query where statement into the repeat region command so only the red class would show up in the list, then reuse the statement with each of the different variables to create a drop down menu with each class listed in the menu bar.
If I can figure this out setting up all 90 classes will be simple copy and paste then typing in a new class value instead of creating 90+ record sets for my menu.
If someone has any ideas I'd appreciate it very much. I may be barking up the wrong tree.
Copy link to clipboard
Copied
It looks like I've stumped the community. Anyone have any ideas about where to look?