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
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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.