Different background on li items


I’m trying to get a list of div boxes. Depending on a category the boxes should have either a black or red background.

This is part of my blueprint

    label: Category
    type: radio
      1: Hotel
      2: Transport

This is each li-item

<?php $count = 0; foreach($projects as $project): ?>


		$style = 'background:';
		$given = $project->cat() = 1 ? 'red;' : 'black;';
		$style .= $given;

		<div class="project-info" style='<?php echo $style; ?>'>Some text</div>


<?php $count++; endforeach; ?>

They all end up the same, either black cat < 1 or red cat < 2. If I use cat = 1 as above everything breaks. Can anyone tell me what I’m doing wrong?

`You have to use a comparison operator instead of an assignment operator; and “1” is a string in this context, not an integer, so:

$given = $project->cat() == "1" ? 'red;' : 'black;';

Thanks a lot texnixe :grinning: