Jump to content

change post author color


christa

Recommended Posts

hi all, in my blog (made by me, no wordpress or similar) i would want to change the color of comments written by author of article

My code is:

$sql = "SELECT author WHERE art_id=...";

//print all comments...
while ($row = mysql_fetch_array($result)) {
if ($_SESSION['ID_user'] == $sql['ID_user'] ) {
$color = "#FFFFFF";
} else {
$color = "#FF0000";
}

echo '<div id="comment" style="background-color: ' . $color . '">post</div>';
}

but the code above print all FFFFFF or all FF0000

 

Where it is wrong? thanks :)

Link to comment
https://forums.phpfreaks.com/topic/223196-change-post-author-color/
Share on other sites

here the complete code:

//print all comments...
while ($row = mysql_fetch_array($result)) {

$sql_user = mysql_query("SELECT u.IDuser FROM users u JOIN articles a ON a.IDuser=u.IDuser AND a.IDart=$_GET['IDart'] WHERE u.IDuser=" . $_SESSION['IDuser'] . "");
$row2 = mysql_fetch_array($sql_user);
   if ($_SESSION['IDuser'] == $row2['IDuser'] ) {
      $color = "#FFFFFF";
   } else {
      $color = "#FF0000";
   }
echo '<div id="comment" style="background-color: ' . $color . '">post</div>';
}

That isn't the same code that's in your first post. Which one is the code that's actually being used? Without the actual code that's causing the actual problem, there's no point even looking at it.

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.