Hello I'm creating a cinema blog using wordpress. I created tv episodes using serialized data with custom text boxes. My problem here is that when ever I unserialize the data I want it to display seasons, episode number, and plot. However since multiple episodes will have the same seasons, I didn't want duplicate season numbers to display multiple times. I use an if statement to get this done; however once in a while I get duplicate seasons as if it is 2 different numbers when it's exactly the same. The make sure it wasn't human error with white space or anything, I input the season numbers using a list box with numbers. Unfortunately I still have that problem.
foreach ($data as $item):
if ($item['season'] !== $old_season) {
echo '<ul class="panel"><h2 class="title">Season '. $item['season'].'</h2>'.
'<li><h2>'.stripslashes(base64_decode($item['title'])).'</h2>'; $old_season = $item['season'];}
echo '<p>Episode'. $item['number']. 'Aired'.stripslashes(base64_decode($item['airdate'])).'</p>'
.'<p>'.stripslashes(base64_decode($item['plot'])).'</p></li>';
endforeach
Any help will be much appreciated!
var_dump($data)and post the results here.$datacoming in? Given your var_dump, season 18 headers would get printed twice, as a season 2 falls in the middle of all the season 18 episodes.$old_seasonwas constantly getting overwritten in the if statement, wiping the fact that some season 18 episodes were previously printed.