PHP/MYSQL Coloring names -


i'm searching ideas how color names. i've got database user information , user color code(#000 or etc.). bellow code makes drop-dow list of users. need color user names color code added database. put code in? names in owner filter

<font color="<?php echo @$user['user_color'];?>"></font> 

and here code prints list of users.

//db_loadhashlist($sql); $owner_combo = arrayselect($owner_list, 'owner_filter_id',                             'class="text" onchange="javascript:document.searchform.submit()"',                             $owner_filter_id, false); // setup title block $titleblock = new ctitleblock('companies', 'handshake.png', $m, "$m.$a"); $titleblock->addcell(('<form name="searchform" action="?m=companies&amp;search_string='                        . dpformsafe($search_string) . '" method="post">' . "\n"                        . '<table><tr><td><strong>' . $appui->_('search')                        . '</strong><input class="text" type="text" name="search_string" value="'                        .  dpformsafe($search_string) . '" /><br />'                        . '<a href="index.php?m=companies&amp;search_string=-1">'                        . $appui->_('reset search') . '</a></td><td valign="top"><strong>'                        . $appui->_('owner filter').'</strong> ' . $owner_combo                        . ' </td></tr></table></form>')); 

sample:

lenon, john(red)

steve, mickey(yellow)

you should stop trying note down color on every single element create in view. use classes instead, classes exist identify groups of element received identical styling rules.

instead should create dynamic style sheet file (css file) each user color defined:

..... .user-styled.user-53846298 { color: #643; } .user-styled.user-45384763 { color: #765; } .user-styled.user-65937405 { color: #ab7; } ..... 

such file can created on-the-fly means of php when requested ordinary, static css file.

then, inside view creation routines mark elements associated specific user a) fact should receive user specific styling , b) of specific user:

..... <form name="searchform" .....>     .....     <select name="search_user" .....>         <option              class="user-styled user-<?= $user['user_id']?>"             value="<?= $user['user_id'] ?>">             <?= $user['user_name'] ?>         </option>         .....     </select>     ..... </form> ..... 

this approach not limited element types or anything. flexible, powerful , performs fine, since dynamically created style definition can cached other css file. allows apply same styling without additional effort dynamic content created means of client side scripting or ajax calls. if fetch additional information single user don't have know users color (or whatever user specific data), since present in style definition. mark user id element , rendered accordingly.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -