spifli Posted June 22, 2009 Share Posted June 22, 2009 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 More sharing options...
flyhoney Posted June 22, 2009 Share Posted June 22, 2009 Remember, '==' is used for equality and '=' is used for assignment i.e. <?php if ($testloot['i_color'] == 'a335ee') { // do something } else if ($testloot['i_color'] == 'ff8000') { // do something else } Link to comment https://forums.phpfreaks.com/topic/163228-solved-ifelse-problem/#findComment-861256 Share on other sites More sharing options...
spifli Posted June 22, 2009 Author Share Posted June 22, 2009 damn, can't believe it was something so silly Thanks a lot! Link to comment https://forums.phpfreaks.com/topic/163228-solved-ifelse-problem/#findComment-861304 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.