Jump to content

Help me guysss....


Go to solution Solved by ignace,

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
Edited by Ch0cu3r
Link to comment
https://forums.phpfreaks.com/topic/285590-help-me-guysss/#findComment-1466189
Share on other sites

  • Solution

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.

Edited by ignace
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...

Edited by subhomoy
Link to comment
https://forums.phpfreaks.com/topic/285590-help-me-guysss/#findComment-1466244
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.