Add css class?

I want to conditionally add a current class to a list. I have set the value of $index earlier in the script and $issue_number is passed in the URL. My last effort was to escape the equal sign and the html quotes around current (see below). I think this is a syntax problem but I’m out of ideas.

if($index == $issue_number) {
		$class='class\\=\\"current\\"';
		} else {
		$class=null;
		
		echo '<li><a'."$class".' href="newsletter_tmp.php?issue_number='."$issue_number".'">'."$date_issue".'</a></li>';
		}

You are wrapping the output in the if statement, excluding output in cases with the statement equating to true.


$class = '';
if($index == $issue_number) {
        $class = 'class="current"';
}
printf('<li><a &#37;s href="newsletter_tmp.php?issue_number=%s">%s</a></li>', $class, $issue_number, $date_issue);

Jake - I see what you mean. Thanks for the help. Beautiful.