Jump to content

IF CONDITIONALS = Solution?


yakabod

Recommended Posts

http://caraudioclips.com/category.php

 

On the left side is a list of categories. I want like 2 or 3 of those categories to be bolded or different font color. How would I go about in achieving this? Would I need to use conditionals as my solution? If there is a certain code I should show you guys, I'll be happy to provide it for you.

 

Thanks alot!

Link to comment
https://forums.phpfreaks.com/topic/69802-if-conditionals-solution/
Share on other sites

how you implement depends on why a specific item should be bolded.

 

is it for only specific names ( Alpine, JBL, Kenwood)

or is there a specific type ( would be defined in a db, or array of those nav items )

 

once you know why each one is different, you're pretty much halfway there.

 

lets assume your list is at some point in an array, and you are looping over each item and creating some sort of html string for output later on....

<?php 


$ArrayToBold = array('Alpine', 'JBL', 'Kenwood' ) ;
$ArrayOfNavItems = ('Alpine', 'JBL', 'Kenwood' , 'Cerwin Vega') ;

$Html = null; 

if ( is_array($ArrayOfNavItems) )  :
foreach ( $ArrayOfNavItems as $item ) :
	if ( in_array($item, $ArrayToBold) ) :
		$Html = '<li><a href="/category_home.php?cid=' . $item . '" class="Bold_ItemLink">' . $item . '</a></li>' . "\r\n" ;
	else : 
		$Html = '<li><a href="/category_home.php?cid=' . $item . '" class="ItemLink">' . $item . '</a></li>' . "\r\n" ;
	endif ; 
    endforeach ; 
endif ; 
?>
<ul>
<?php echo $Html; ?>
</ul>

 

 

hope this helps and good luck

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.