Jump to content

[SOLVED] If/else problem


spifli

Recommended Posts

Hey,

 

I have been looking for a while now, but can't seem to find the problem in following code I made.

The query it self works and the data is shown on my website as well, but everything is processed as being in the first if.

 

I have a table called "loot" with fields "l_itemid" ...

Another table called "items" with fields "i_itemid" "i_name" "i_color" ...

there are 3 "i_color" values 0070dd, a335ee and ff8000

 

The query  has to show the last 6 records added but leave out the once with "i_color"  0070dd (this is working)

 

It shows the records of the last 6 records like its suppose to ( both "i_color" a335ee as ff8000, but all records are shown as they were in the first IF and thus some get the wrong font color

 

$query = "SELECT * FROM loot INNER JOIN items ON loot.l_itemid = items.i_itemid 
  where i_color<>'0070dd' and LENGTH(i_name)<33  
  ORDER BY loot.l_raidid DESC LIMIT 0,7 ";
$sql = mysql_query($query) or die ( mysql_error( ) );

$testloot = mysql_fetch_array( $sql );

while($testloot = mysql_fetch_array( $sql ))
{
if($testloot['i_color']='a335ee') 
  {
  Print "<a href='?q=node/7&rshow=loot'>i.</a><a style='color: #a335ee' href=http://www.wowhead.com/?item=".$testloot['l_itemid'] ."> ".$testloot['i_name'] ."</a><br/> ";
  }
  elseif($testloot['i_color']='ff8000') 
  {
  Print "<a href='?q=node/7&rshow=loot'>i.</a><a style='color: #ff8000' href=http://www.wowhead.com/?item=".$testloot['l_itemid'] ."> ".$testloot['i_name'] ."</a><br/> ";
  }
}

Link to comment
https://forums.phpfreaks.com/topic/163228-solved-ifelse-problem/
Share on other sites

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.