dsaba Posted March 3, 2007 Share Posted March 3, 2007 i'm making a search cloud page, where the latest keywords that have been searched are listed in a table it pulls this information from my database now I want to change the color of the link depending on their serach count for example keyword > 100 counts - make the link green keyword <100 counts make the link blue is there a way to do this in php? also i realize that you can use css to change link colors in a page, but I don't know how to use css to specifically change only certain links, and make those certain colors thanks Link to comment https://forums.phpfreaks.com/topic/41004-solved-change-link-color-in-php/ Share on other sites More sharing options...
ted_chou12 Posted March 3, 2007 Share Posted March 3, 2007 <?php $number = //however you want to get your resutls, I believe you should use mysql_count_rows() if ($number > 100) {echo "<a href=\"http://\"><font color=\"#66CD00\">Link</font></a>";} else {echo "<a href=\"http://\"><font color=\"#007FFF\">Link</font></a>";} ?> Ted Link to comment https://forums.phpfreaks.com/topic/41004-solved-change-link-color-in-php/#findComment-198551 Share on other sites More sharing options...
dsaba Posted March 3, 2007 Author Share Posted March 3, 2007 i am using css to define all links in all of my pages already, the search cloud page would also have these css rules would the css not overwrite the html I specify for a link color with that php code? Link to comment https://forums.phpfreaks.com/topic/41004-solved-change-link-color-in-php/#findComment-198555 Share on other sites More sharing options...
ted_chou12 Posted March 3, 2007 Share Posted March 3, 2007 no, css dont overwirte html. however, if you wish to use css to do this, please do post your css code as well. Ted Link to comment https://forums.phpfreaks.com/topic/41004-solved-change-link-color-in-php/#findComment-198557 Share on other sites More sharing options...
dsaba Posted March 3, 2007 Author Share Posted March 3, 2007 thank you very much you told me what i needed to know really my problem was this: how to change link color specifically in html, that css doesn't overwrite, and you told me that Link to comment https://forums.phpfreaks.com/topic/41004-solved-change-link-color-in-php/#findComment-198559 Share on other sites More sharing options...
kenrbnsn Posted March 3, 2007 Share Posted March 3, 2007 You can try something like this: <?php $link_color = ($keyword < 100)?'lime':'lightblue'; echo '<a style="color:' . $link_color . '" href="you.link.here">text</a>'; ?> Ken Link to comment https://forums.phpfreaks.com/topic/41004-solved-change-link-color-in-php/#findComment-198576 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.