subhomoy Posted January 22, 2014 Share Posted January 22, 2014 Hello every body actually i'm going to create a chat script and i need some idea... suppose two persons ( x and y ) are chatting together... I want to create two different different backgrouns for those messages.. Like x's messages are shown in dark div background and y's background is light..... How can i acheive this... I just need the idea..... Thank u in advance.... Link to comment https://forums.phpfreaks.com/topic/285590-help-me-guysss/ Share on other sites More sharing options...
Ch0cu3r Posted January 22, 2014 Share Posted January 22, 2014 Sounds to me you need to alternate the background color for each message. To do this you'll need to initiate a counter, for this we'll use the variable $i. And we'll define the two background colors $i = 0; // init counter // define background colors $bg_color1 = '#999'; $bg_color2 = '#666'; Now when displaying each messsage you'd do have this $bg_color = (++$i % 2 == 0) ? $bg_color1 : $bg_color2; // alternavte background color echo '<div style="background-color: $bg_color">$message</div>'; // set the background color for the message Link to comment https://forums.phpfreaks.com/topic/285590-help-me-guysss/#findComment-1466189 Share on other sites More sharing options...
ignace Posted January 22, 2014 Share Posted January 22, 2014 It's easier if you set the colors specific from the user's perspective. So each user sees his own messages with a green background, while they see all other's messages in different colors. This also means you only need a few colors versus one specific color for each member. Link to comment https://forums.phpfreaks.com/topic/285590-help-me-guysss/#findComment-1466198 Share on other sites More sharing options...
subhomoy Posted January 23, 2014 Author Share Posted January 23, 2014 Thank u guyss for the help... but i think u didn't understood the questions... Ch0cu3r what if same persons sends two message parallery then they will have both different background... I dont want tthat...What i want is that ( x ) will have always the same background irrespective of how many post he posted and this is same for ( Y ) also... Link to comment https://forums.phpfreaks.com/topic/285590-help-me-guysss/#findComment-1466244 Share on other sites More sharing options...
ignace Posted January 23, 2014 Share Posted January 23, 2014 We understood it correctly, you misinterpreted. My solution solves that problem. Simply assign a color to each person in the chat. Link to comment https://forums.phpfreaks.com/topic/285590-help-me-guysss/#findComment-1466250 Share on other sites More sharing options...
subhomoy Posted January 23, 2014 Author Share Posted January 23, 2014 Thanks for the help..... Link to comment https://forums.phpfreaks.com/topic/285590-help-me-guysss/#findComment-1466265 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.