Jump to content

change post author color


christa
 Share

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
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>';
}

Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

×
×
  • 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.