Jump to content

Recommended Posts

when you use mysql_query(), that returns a result source.  You must then get the data out of the result source using mysql_result, mysql_fetch_assoc, mysql_fetch_row, or similar (follow the links).  For example, if one of your database columns is called "foo" and you want $col1 to be assigned "#CCC" if the value of the "foo" column is "bar", and "#fff" if not, you would do something like this:

 

$post = "SELECT * FROM dbKarma";
$post_query = mysql_query($post);

// loop through each row of the returned query results.. 
while ($row = mysql_fetch_assoc($post_query)) {
  // if column 'foo' equals 'bar'...
  if ($row['foo'] == 'bar') {
    $col1 = "#CCC";
  } else {
    $col1 = "#fff";
  }
}

Hello

 

Another question. Slightly unrelated.

 

is this possible? I am basically trying to add if statements to css.

 

 

include ("dbConfig.php");
header('Content-type: text/css');
$user = $_SESSION["valid_id"];

$post = "SELECT * FROM dbPosts";
$post_query = mysql_query($post);

while ($row = mysql_fetch_assoc($post_query)) {

if ( $row['username_id'] == $user )
{
$col1 = "#CCC";
}
else
{
$col1 = "#fff";
}
}



echo ("
  #postbox {

  width: 700px ;
  margin-left: auto ;
  margin-right: auto ;
height: 0px auto;
height-top: 10px;
border-width:1px;
border-style:dashed;
border-color:#353535;
background-color:$col1;
font-size:24px;
}
");

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.