Help with COUNT on a group

Can’t thank you enough. Posted elsewhere on the SP forums asking for a book recommendation so I can learn this level of stuff properly.

Thank you x 100. :slight_smile:

one final question if I may…

how would I get each movie itself to display, for example, a different background color based on whether or not it is watched or unwatched? or even a little icon img to say it’s watched or unwatched. either. I would like to sort and color code them based on their status.

GENRE - 2/1 (Watched/Unwatched)

movie1 <-these
movie2 <-these
movie3 <-these

would that just involve adding to the same array code or is that more complicated?

Nope, in fact, what you need is already in the array.

Where you have that <div> for your movie, just add class=“{$movie[‘moviestatus’]}”.

That’ll put the movie status as a class for each movie.

Then in your CSS, just create the CSS for each of them:

.U { background-color: #F00; }
.W { background-color: #00F; }

Is it ok to have it like this?

echo '<div id="movie" class="$movie[moviestatus]">';

I ask because I got errors the other way (“Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’”)

but then for some reason the CSS doesn’t seem to be working (been a long time since I’ve used any CSS so I may be doing it wrong heh)

CSS looks like this:

#movie .U {background-color: #F00;}
#movie .W {background-color: #00F;}

Try this instead:

echo "<div id='movie' class='" .$movie[moviestatus] ."'>";

Thanks John, with that method the page actually loads, but gives me this:

Notice: Use of undefined constant moviestatus - assumed 'moviestatus'

does that mean that the class is just wrong?

My apologies for being annoying too. :smiley:

Champion, managed to clear the syntax error and now move on to the next error :slight_smile:

My old C++ teacher, Robin, always used to say “read and understand the error messages”.

The error you are getting back says “…undefined constant moviestatus”.

I think the code should be:

   echo "<div id='movie' class='" .$movie['moviestatus'] ."'>";  

On the off-chance that does not work then change the $debug value to 1 and display your movie array.

  $debug=0; // toggle to 1 to display values
    echo '<pre>';
    echo '</pre>';


Thanks again - that worked, but the CSS still doesn’t apply. So I tried the debug thingy, and got this:

[moviename] => MOVIE1
[moviestatus] => W
[genre_abbreviation] => GENRE1

which makes me think the css I have really should work:

#movie .W {background-color: #AAAAAA;}

I’ve tried variations on it, including just ‘background:’

ugh hm. so close!


just .W works, no #movie!


You’re both legendary. Thanks so much. Promise not to bump with further queries… :smiley: