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!
I would agree that IP address might not be the best solution, but to do that:
Note that the colour will change each time the page loads.