Jump to content

Recommended Posts

Hello

 

I have three tables

 

users(user id, vote id)

posts(post id, user id, post)

vote(vote id, post id, up, down)

 

This is my while loop.

It outputs all the posts users have made.

each post has a box around it.

 

My div id 'postbox' is stored in a seperate CSS file containing a colour value.

How do I change the colour value depending on data in vote(up, down)

 

while( $i < $row = mysql_fetch_array($query))

  {

  echo "<div id=" . "postbox". ">";

  echo $row['post'];

  echo  "</div>;

  }

How do I change the colour value depending on data in vote(up, down)

What are the possible values for up and the possible values for down?

 

 

 

 

while( $i < $row = mysql_fetch_array($query))

  {

  echo "<div id=" . "postbox". ">";

  echo $row['post'];

  echo  "</div>;

  }

 

Could be:

while( $i < $row = mysql_fetch_array($query))
  {
      if($row['up'] == yes)
         {
            $postboxColor = 'green';
         }
      else{
            $postboxColor = 'red';
            }
echo <<<_END
<div id="postbox $postboxColor">
   $row['post']
</div>
_END;
  }

 

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.