Jump to content

less than issue


aebstract

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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());

Link to comment
Share on other sites

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>"; }

Link to comment
Share on other sites

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.