aebstract Posted April 13, 2010 Share Posted April 13, 2010 if ($r[q1] == x) { $r[q1] = ''; } elseif (($r[q1] < $r[q2]) && ($r[q1] < $r[q2])) { $r[q1] = "<font color=red>$r[q1]</font>"; } if ($r[q2] == x) { $r[q2] = ''; } elseif (($r[q2] < $r[q1]) && ($r[q2] < $r[q3])) { $r[q2] = "<font color=red>$r[q2]</font>"; } if ($r[q3] == x) { $r[q3] = ''; } elseif (($r[q3] < $r[q1]) && ($r[q3] < $r[q2])) { $r[q3] = "<font color=red>$r[q3]</font>"; } Here are my results: http://outlawracing.com/index.php?page=ladders&event=2 Curtis Rhodesdropdrop4.478 @ 213.6 Ken Rainwater4.5 @ 156.554.98 @ 2115.6 @ 203.62 T Johnson6.03 @ 205.45.85 @ 211.34.99 @ 218.11 Brian Hurrell5.943 @ 2095.789 @ 215.225.804 @ 209.37 So, I'm wondering, what is causing it to not just get one value with the above code? Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted April 13, 2010 Share Posted April 13, 2010 Is x a constant? Also, there is a redundancy in your first elseif statement. You're matching the same thing. Take a closer look. Quote Link to comment Share on other sites More sharing options...
aebstract Posted April 13, 2010 Author Share Posted April 13, 2010 Ah, thought I had those sorted out. Fixed it and it didn't change this particular output. If the value in the database is x, then I want it to display as just a blank result. For the admins on this entering an x will basically clear out the field. So it is actually an x in the database, I just want it to show as blank, if it isn't an x it is a number. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted April 13, 2010 Share Posted April 13, 2010 Can you please post up the pertinent code? The code snippet you posted doesn't print anything. Please show enough code to allow us to diagnose the issue. Thanks! Quote Link to comment Share on other sites More sharing options...
aebstract Posted April 13, 2010 Author Share Posted April 13, 2010 That code is the ONLY thing that generates the colors. Then the variable is just echoed out. You have plenty of code to work with right there. You have the values and the line that is doing the figuring. $content .= "$r[q1]"; Is this line really important to you for this issue? Here's the query for giggles, though I don't know what you would really need it for either, the values are correct. $query = mysql_query(" SELECT registrations.firstname, registrations.lastname, participants.q1, participants.q2, participants.q3, participants.q1s, participants.q2s, participants.q3s, participants.id FROM events INNER JOIN participants ON participants.eventid = $_GET[event] INNER JOIN registrations ON registrations.id = participants.regid WHERE events.id = $_GET[event] AND registrations.class = '$var' ORDER BY LEAST(q1, q2, q3) ") or DIE(mysql_error()); Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted April 13, 2010 Share Posted April 13, 2010 The issue is that you're changing the value of the variables each time through the if statement. After the first one, $r['q1'] will be a string. Then you're using the string for comparison. Quote Link to comment Share on other sites More sharing options...
aebstract Posted April 13, 2010 Author Share Posted April 13, 2010 Ah, thanks: $t1 = $r[q1]; $t2 = $r[q2]; $t3 = $r[q3]; } elseif (($t1 < $t2) && ($t1 < $t3)) { Quote Link to comment Share on other sites More sharing options...
Psycho Posted April 13, 2010 Share Posted April 13, 2010 I would add that I *think* you are taking the wrong approach in your comparisons. Instead of checking if r1 < r2 and r3 you should be checking if r1 is equal to the minimum time. Otherwise if you had two minimum times that were equal - neither would be in red. This may be a little more efficient and accurate: $roundMin = min($r['q1'], $r['q2'], $r['q3']); //Remove 'x' $r['q1'] = str_replace('x', '', $r['q1']); $r['q2'] = str_replace('x', '', $r['q2']); $r['q3'] = str_replace('x', '', $r['q3']); //Format minimum(s) in red if ($r['q1']==$roundMin) { $r['q1'] = "<font color=red>{$r['q1']}</font>"; } if ($r['q2']==$roundMin) { $r['q2'] = "<font color=red>{$r['q2']}</font>"; } if ($r['q3']==$roundMin) { $r['q3'] = "<font color=red>{$r['q3']}</font>"; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.