The first part works just fine. The list only shows up when one of the class values = red. The repeat region, however, repeats all of the links so I end up with this: (as expected)

page_01
page_02
page_03
page_04
page_05
page_06

What I want is this:

page_01
page_03
page_06

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.

firepages

08-21-2012, 12:52 AM

I am not getting what you mean by `repeat region` sorry ?
but you could....

Thanks for the reply. The code isn't producing any results so there may be a typo someplace. I'm doing some more research.

Thanks again.

Fou-Lu

08-21-2012, 06:32 PM

The same error exists in your original code:

while ($row_contentRS = mysql_fetch_assoc($row_contentRS));

Regardless of where you pull a while loop either in a do/while or in a while, this overwrites the value of $row_contentRS, so you cannot fetch from it again (assuming $row_contentRS is a resultset). Change the assignment to a different variable name.

I'm confused on what you are talking about here as well. Simply pulling with a where condition will only produce the results matching that where condition. In this case, where class is red.

Results sets can be reset by calling the seek method. Put it back to row 0, and it will start again. Alternatively, fetch it in an array and each time a foreach is called it automatically calls a reset() on the array.

If you were to need all classes at the same time, you can fetch everything into an array and then use an array_filter to show only what you need. That doesn't seem to be the case here, but just in case you need to make use of it in the future I thought it would be best to mention. This is similar to what firepages has here:

I can easily do this by creating a simple if statement to echo the Class List and then using a separate record set for each page list by filtering the records by a WHEN class = (the selected color), then adding this PHP code for each page class:

What I'd like to do is set up a single record set that just pulls down all records and sorts them and then filter the results so that each <li>Page #</li> could be sorted by class. I have everything working except the class. No matter what method I've tried I end up with all of the pages being displayed in each list (after clearing the while / fetch query) or no records being displayed with the suggestion made by firepages.

I'm going to try and work with Fou-Lu's suggestion this evening. I'll try the array first. The prototype page with 90+ record sets is quite slow to load and maintenance will be a real nightmare.

Fou-Lu

08-23-2012, 06:25 PM

You're still overwriting the variables.
For simplicity, I'd simply use filters, although it does mean you have to explicitly write the functions for it since they do not accept any user parameters. This method means you select all of the records from the dataset into an array and use that in PHP. There are literally a dozen ways to do this exact task, from manual iterations of the resultsets, to splitting into parts and iterating, to combining and using recursion, etc etc.
What I'll do is combine the entire recordset into a flat array, then filter them by class colour, and then iterate each one to build the list inline. If it always uses only the three colours, then this is fine. If it uses more colours, then you do not want to do this and a better solution is to create a multidimensional array like firepages has, and then use recursion to build the list.