Jump to content

Help me guysss....


subhomoy

Recommended Posts

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

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

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

Thank u guyss for the help...  but i think u didn't understood the questions...

 

 icon_share.png 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

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.