Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7787267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:36:34+00:00 2026-06-01T20:36:34+00:00

Didn’t know how to word the title sorry. Basically I have a comments system,

  • 0

Didn’t know how to word the title sorry. Basically I have a comments system, it works really simply, selects the uid of the post from a DB, then just outputs the comments tied to that UID from another DB.

The nature of the comments system is that every poster is anonymous, because of that, it’s hard to track whether you’re communicating with the same person or not, for that reason, I want to make the div wrapped around the comment be a specific colour, and for each comment by that person on that post to be that colour. The only thing that ties a users comments together is the IP address.

My code thus far:

$sql = "SELECT * FROM anonpost_com WHERE uid = '$uid' ORDER BY date DESC";


$result = mysql_query($sql) or print ("Can't select entry from table anonpost.<br />" . $sql . "<br />" . mysql_error());

while($row = mysql_fetch_array($result)) {
    $date = date("l F d Y", strtotime($row['date']));
    $comment = stripslashes($row['comment']);
    $uid = ($row['uid']);
    $cid = ($row['cid']);
    $ip = ($row['ip']);


         ?>



<div id="comments" style="border:1px solid <?php echo $colour; ?>;">
<p><?php echo $comment; ?></p>
<h4>by <i>Anonymous</i> on <?php echo $date; ?></h4>
</div>
<?php
}
?>

$colour comes from:
$colour = dechex(rand(0,10000000);
But I’m unsure how to make $colour the same for every instance of the same IP on a comment…

Any help would be appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:36:35+00:00Added an answer on June 1, 2026 at 8:36 pm

    I would agree that IP address might not be the best solution, but to do that:

    $sql = "SELECT * FROM anonpost_com WHERE uid = '$uid' ORDER BY date DESC";
    
    $colours = array();
    $result = mysql_query($sql) or print ("Can't select entry from table anonpost.<br />" . $sql . "<br />" . mysql_error());
    
    while($row = mysql_fetch_array($result)) {
        $date = date("l F d Y", strtotime($row['date']));
        $comment = stripslashes($row['comment']);
        $uid = ($row['uid']);
        $cid = ($row['cid']);
        $ip = ($row['ip']);
        if (!isset($colours[$ip])) {
            $colours[$ip] = dechex(rand(0,10000000);
        }
        $colour = $colours[$ip];
    
    
             ?>
    
    
    
        <div id="comments" style="border:1px solid <?php echo $colour; ?>;">
            <p><?php echo $comment; ?></p>
            <h4>by <i>Anonymous</i> on <?php echo $date; ?></h4>
        </div>
    <?php
    }
    ?>
    

    Note that the colour will change each time the page loads.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I didn't really know how to phrase this question, its quite strange. I have
I didn't really know how to formulate the title. But this is my problem.
Didn't know how else to put this. Say I have a JavaScript method that
I didn't fully understand the concept of threads I have some questions. Assume we
I didn’t know about the <button> tag until today.
I didn't configure the HTTPS on my domain so I'm not really sure where
I didn't find much in tutorials on this specific question.. So I have a
Didn't even know how to exactly phrase this question, but here is the the
I didn't know how to Google this, it always came up with answers I
This didn't work: Setting the umask of the Apache user Arch doesn't have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.