Solved

# Generate Table to Line Up Numbers on a Scale, Like a Graph

Posted on 2007-10-18
266 Views
I want to make a PHP function that can take two arrays like:

\$names = array('Moe', 'Don', 'Record Two Weeks Ago', 'Rick', 'Mary', 'Last Weeks's Record', 'Tom', 'Record Three Weeks Ago', 'Jack', 'Jill', 'Bob');   and

\$scores = array('22.3', '27.8', '32.0', '34.4', '35.9', '40.0', '44.2', '46.2', '48.1', '52.3', '58.0');

and print results like below.  (It's supposed to look like a vertical ruler, with markers for each name on the right side of "ruler", next to the rule point that is closest to the person's score. For example, Mary's score of 35.9 is closest to 36, so her marker goes to the right of 36.
To build the "ruler", I think it needs to test what are the lowest and highest scores, to make the "ruler" a little lower and higher than those scores. For example, 20 is the whole number multiple of 2 at least 2 points below 22.3.  And 60 is the whole number, multiple of 2, at least two points above 58.

60 |
-- |  58.0 Bob
-- |
-- |
-- |  52.3 Jill
50 |
-- |  48.1 Jack
-- |  - - - 46.2 Record Three Weeks Ago
-- |  44.2 Tom
-- |
40 | ---- 40.0 Last Week's Record ----
-- |
-- |  35.9 Mary
-- |  34.4 Rick
-- |- - - 32.0 Record Two Weeks Ago
30 |
-- |  27.8 Don
-- |
-- |
-- |  22.3 Moe
20 |

That's just to give you an idea. I actually want to use a CSS-enhanced HTML table, like this:

<table border=0 cellpadding=0 cellspacing=0 style="font: 11pt arial">
<tr>
<td style="border-right: thin solid blue"><b>60</b>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>
<td>&nbsp;58.0 Bob</td>
</tr>
<tr>
<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>
<td>&nbsp;</td>
</tr>
<tr>
<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>
<td>&nbsp;</td>
</tr>
<tr>
<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>
<td>&nbsp;52.3 Jill</td>
</tr>
<tr>
<td style="border-right: thin solid blue"><b>50</b>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>
<td>&nbsp;48.1 Jack</td>
</tr>
<tr>
<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>
<td>&nbsp;--- 46.2 Record Three Weeks Ago</td>
<tr>
<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>
<td>&nbsp;44.2 Tom</td>
</tr>
<tr>
<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>
<td>&nbsp;</td>
</tr>
<tr>
<td style="border-right: thin solid blue"><b>40</b>&nbsp;</td>
<td>&nbsp;---- 40.0 Last Week's Record ----</td>
</tr>
<tr>
<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>
<td>&nbsp;</td>
</tr>
<tr>
<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>
<td>&nbsp;35.9 Mary
</td>
<tr>
<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>
<td>&nbsp;34.4 Rick</td>
</tr>
<tr>
<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>
<td>&nbsp;--- 32.0 Record Two Weeks Ago</td>
</tr>
<tr>
<td style="border-right: thin solid blue"><b>30</b>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>
<td>&nbsp;27.8 Don
</td>
</tr>
<tr>
<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>
<td>&nbsp;</td>
<tr>
<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>
<td>&nbsp;</td>
</tr>
<tr>
<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>
<td>&nbsp;22.3 Moe</td>
</tr>
<tr>
<td style="border-right: thin solid blue"><b>20</b>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>

Can a PHP expert show me how to generate this kind of table with all the data in the correct cells, and with the correct "ruler" scale?  (And suggest how to handle cases where two scores both need to be to the right of one ruler point, such as 27.9 and 28.2 are both close to 28.) Thanks in advance.
0
Question by:FrankTech

LVL 2

Expert Comment

arg....

Look at the array functions at www.php.net  you might be able to use a two element array easier.

but you will need to:

Sort your array decending by scores,
setup a loop for your ruler, for(\$ruler==60;\$ruler>0; \$ruller-10) {
do a scan trough your array and echo "<TD> ....."
}
or a do while and decrement ruler as you go through your array and find a score=ruler-10
0

Author Comment

Thanks for the suggestions. Note, the rule would not always 20 to 60. It depends on the data. It could be anything. The top and bottom of the ruler just needs to be a little lower and higher than the lowest and highest data (and it should be a whole number, muliple of 2).  As this is a a 500-point question, I am hoping for more detail and some working code. Thanks.
0

LVL 7

Expert Comment

Heres your example code ;)

<?php
@session_start();
\$scores = array(array('name'  => 'bob',
'score' => '58.0'
),
array('name'  => 'jill',
'score' => '52.3'
),
array('name'  => 'jack',
'score' => '48.1'
),
array('name'  => 'tom',
'score' => '44.2'
),
array('name'  => 'mary',
'score' => '35.9'
),
array('name'  => 'rick',
'score' => '34.4'
),
array('name'  => 'don',
'score' => '27.8'
),
array('name'  => 'moe',
'score' => '23.3'
)
);
\$high_score = (int) 0;
\$i = count(\$scores);
\$j = 0;
for(\$k = 0; \$k < \$i; \$k++) {
if(\$scores[\$j]['score'] > \$high_score) {
\$high_score = (int) \$scores[\$j]['score'];
}
\$j++;
}
\$rulerTop = substr(\$high_score, 0, 1);
\$rulerTop++;
\$rulerTop .='0';
echo('<table>');
for(\$l = \$rulerTop; \$l >= 10; \$l--) {
echo('<tr>');

if(substr(\$l, 1, 2) == '0') {
echo('<td style="border-right: thin solid blue"><b>'."\$l".'</b>&nbsp;</td>');
} else {
if(\$l & 1) {
echo('<td valign="middle" style="text-align:right; border-right: thin solid blue"></td>');
} else {
echo('<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>');
}
}

\$n = '';
for(\$m = 0; \$m < \$i; \$m++) {
if(round(\$scores[\$m]['score']) == \$l) {
\$n .= '<td>&nbsp;';
\$n .= \$scores[\$m]['score'];
\$n .= '&nbsp;';
\$n .= ucwords(\$scores[\$m]['name']);
\$n .= '</td>';
}
}
echo("\$n");
echo('</tr>');
}
echo('</table>');
?>

Enjoy ;)
0

LVL 7

Expert Comment

And sorry jaxn but that was no where near a solution =D
0

LVL 7

Expert Comment

On my example I made it so it sets the height of the ruler depending on what the highest score is. For now we are using an array but in the future I would recommend using a mysql database then for your previous weeks high scores the timestamp in the DB will calculate that ;)
0

Author Comment

gemdeals395,
That's great.
There's a bug: beside Moe 23.3, there is a blank cell to the left, instead of a --| .  (I think the table has inserted a blank row beside him.) How would we fix that?
Also, it seems like it would be better to end the bottom of the ruler at 20 instead of 10, since there are no scores lower than 22.  How would the routine be adjusted to be more conservative on the bottom end of the ruler?  Thanks.
0

LVL 7

Expert Comment

Ok, This has had the base changed to 20 and Im working on the positioning of the numbers. The problem occurs when you only want to display the even numbers with -- then line up everything to the right because when you hit the odd number it suddenly fills the cell and so you see it expanded with only a line and no dashes. The trick looks like its gonna be in css as in this example its really close just a little to the bottom but its not expanding the cell.

<?php
@session_start();
\$scores = array(array('name'  => 'bob',
'score' => '58.0'
),
array('name'  => 'jill',
'score' => '52.3'
),
array('name'  => 'jack',
'score' => '48.1'
),
array('name'  => 'tom',
'score' => '44.2'
),
array('name'  => 'mary',
'score' => '35.9'
),
array('name'  => 'rick',
'score' => '34.4'
),
array('name'  => 'don',
'score' => '27.8'
),
array('name'  => 'moe',
'score' => '23.3'
)
);
\$high_score = (int) 0;
\$i = count(\$scores);
\$j = 0;
for(\$k = 0; \$k < \$i; \$k++) {
if(\$scores[\$j]['score'] > \$high_score) {
\$high_score = (int) \$scores[\$j]['score'];
}
\$j++;
}
\$rulerTop = substr(\$high_score, 0, 1);
\$rulerTop++;
\$rulerTop .='0';
echo('<table>');
for(\$l = \$rulerTop; \$l >= 20; \$l--) {
echo('<tr>');

if(substr(\$l, 1, 2) == '0') {
echo('<td style="border-right: thin solid blue"><b>'."\$l".'</b>&nbsp;</td>');
} else {
if(\$l & 1) {
echo('<td valign="middle" style="text-align:right; border-right: thin solid blue"></td>');
} else {
echo('<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>');
}
}

\$n = '';
for(\$m = 0; \$m < \$i; \$m++) {
if(round(\$scores[\$m]['score']) == \$l) {
\$n .= '<td><div style="position: absolute;">&nbsp;';
\$n .= \$scores[\$m]['score'];
\$n .= '&nbsp;';
\$n .= ucwords(\$scores[\$m]['name']);
\$n .= '</div></td>';
}
}
echo("\$n");
echo('</tr>');
}
echo('</table>');
?>

Ill see about the css ;)
0

LVL 7

Expert Comment

Ok, This one is working perfect and wont expand the odd cells :) Enjoy

<?php
@session_start();
\$scores = array(array('name'  => 'bob',
'score' => '58.0'
),
array('name'  => 'jill',
'score' => '52.3'
),
array('name'  => 'jack',
'score' => '48.1'
),
array('name'  => 'tom',
'score' => '44.2'
),
array('name'  => 'mary',
'score' => '35.9'
),
array('name'  => 'rick',
'score' => '34.4'
),
array('name'  => 'don',
'score' => '27.8'
),
array('name'  => 'moe',
'score' => '23.3'
)
);
\$high_score = (int) 0;
\$i = count(\$scores);
\$j = 0;
for(\$k = 0; \$k < \$i; \$k++) {
if(\$scores[\$j]['score'] > \$high_score) {
\$high_score = (int) \$scores[\$j]['score'];
}
\$j++;
}
\$rulerTop = substr(\$high_score, 0, 1);
\$rulerTop++;
\$rulerTop .='0';
echo('<div name="div" style="position: relative;">');
echo('<table>');
for(\$l = \$rulerTop; \$l >= 20; \$l--) {
echo('<tr>');

if(substr(\$l, 1, 2) == '0') {
echo('<td style="border-right: thin solid blue"><b>'."\$l".'</b>&nbsp;</td>');
} else {
if(\$l & 1) {
echo('<td valign="middle" style="text-align:right; border-right: thin solid blue"></td>');
} else {
echo('<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>');
}
}

\$n = '';
for(\$m = 0; \$m < \$i; \$m++) {
if(round(\$scores[\$m]['score']) == \$l) {
\$n .= '<td style="padding-top: 0px; padding-left: 0px; padding-right: 0px; padding-bottom: 0px;"><div id="'."\$m".'outer" name="'."\$m".'outer" style="position: relative;"><div id="'."\$m".'inner" name="'."\$m".'inner" style="position: absolute; bottom: -12px;">&nbsp;';
\$n .= \$scores[\$m]['score'];
\$n .= '&nbsp;';
\$n .= ucwords(\$scores[\$m]['name']);
\$n .= '</div></div</td>';
}
}
echo("\$n");
echo('</tr>');
}
echo('</table>');
echo('</div>');
?>
0

Author Comment

Thank you. If looked good in Firefox but I had to play with the CSS a little more to make it line up right in IE6 by using "<div id="'."\$m".'inner" name="'."\$m".'inner" style="position: absolute; bottom: -20px; padding-left: 10px;"
I ran across an interesting problem when testing soem different data: try Rick = 35.5.  But his and Mary's 35.9 score should go beside 36, but they're getting jumbled together (one top of the other) via CSS.  I wonder if there's any way to detect that two scores are trying to line up beside the same mark, and somehow make them go side by side instead of on top of each other.
Also, how would I automate setting the proper lower number of the ruler (e.g., 20 here).  The '20' is hardcoded in your script; I would like have it calculated based on the lowest score, like you have the top mark caculated based on the highest score.
0

Author Comment

gemdeals395,
I came up with this routine to calculate the \$rulerBottom dynamically instead of hard-coded:

\$scoresarray = \$scores;

foreach (\$scoresarray as \$key => \$row) {
\$score[\$key] = \$row['score'];
}
array_multisort(\$score, SORT_ASC, \$scoresarray);
\$low_score = \$scoresarray[0]['score'];
\$rulerBottom = substr(\$low_score, 0, 1);
\$rulerBottom .='0';

Now I can change the hard-coded "20" in
for(\$l = \$rulerTop; \$l >= 20; \$l--) {

to the dynamically-calculated
for(\$l = \$rulerTop; \$l >= \$rulerBottom; \$l--) {

But I still need help to modify the code to handle cases where two or more scores need to line up beside the same mark, such as Rick = 35.5  and Mary = 35.9 .

I would like it to look like
36  |  35.9 Mary, 35.5 Rick

where the higher number--Mary--is on the left, and the lower number--Rick--is on the right.  How could we do that?
0

Author Comment

OK, I came up with a version based on your first solution (the one with plain tables, no divs).  Because it does not use divs, it is more browser cross-compatible.
It handles odd numbers, by rounding each score to the nearest even number before comparing it to the rule marks, which are de-incremented by 2's from the highest even-number score. So it does not have the problem of blank rows when the number would have rounded to an odd number.
It also puts multiple scores/names on one line when appropriate, such as "36  |  35.9 Mary, 35.5 Rick".   (And it puts the comma ,  in between the multiple scores.)
Also, it detects if the name contains the word "Record." If it does, it puts "<---" and "---" around that line.  It also sets the ruler bottom dynamically, based on the lowest score.

So it seems like everything is working right, thanks to your great sample code that led me in the right direction.  Here's my latest version. Maybe you can suggest some improvements?  Thanks!

<?php

\$scores = array(array('name'  => 'Bob',
'score' => '57.3'
),
array('name'  => 'Jill',
'score' => '52.3'
),
array('name'  => 'Jack',
'score' => '48.1'
),
array('name'  => 'Tom',
'score' => '45.1'
),
array('name'  => 'Mary',
'score' => '35.9'
),
array('name'  => 'Rick',
'score' => '35.4'
),
array('name'  => 'Don',
'score' => '27.2'
),
array('name'  => 'Moe',
'score' => '23.3'
),
array('name'  => 'John',
'score' => '20.9'
),
array('name'  => 'Record 3 Weeks Ago',
'score' => '44.2'
),
array('name'  => 'Record Last Week',
'score' => '40.0'
),
array('name'  => 'Record 2 Weeks Ago',
'score' => '31.0'
)
);
\$high_score = (int) 0;
\$i = count(\$scores);
\$j = 0;
for(\$k = 0; \$k < \$i; \$k++) {
if(\$scores[\$j]['score'] > \$high_score) {
\$high_score = (int) \$scores[\$j]['score'];
}
\$j++;
}
\$rulerTop = substr(\$high_score, 0, 1);
\$rulerTop++;
\$rulerTop .='0';

\$scoresarray = \$scores;
foreach (\$scoresarray as \$key => \$row) {
\$score[\$key] = \$row['score'];
}
array_multisort(\$score, SORT_ASC, \$scoresarray);
\$low_score = \$scoresarray[0]['score'];
\$rulerBottom = substr(\$low_score, 0, 1);
\$rulerBottom .='0';

echo("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"font: 10pt arial\">");

for(\$l = \$rulerTop; \$l >= \$rulerBottom; \$l-=2) {  // increment by -2
echo("<tr height=\"10\">\n");

if(substr(\$l, 1, 2) == '0') {
echo("<td style=\"border-right: thin solid blue\"><b>"."\$l"."</b>&nbsp;</td>\n");

} else {
echo("<td valign=\"middle\" style=\"text-align:right; border-right: thin solid blue\">--</td>\n");
}

\$n = '';
\$count = 0;
for(\$m = 0; \$m < \$i; \$m++) {
\$nearest2a = round(\$scores[\$m]['score']/2,  0) * 2; // round score to nearest even number
if ( \$nearest2a == \$l ) {
\$n .= '<td>';

for(\$m = 0; \$m < \$i; \$m++) {
\$nearest2b = round(\$scores[\$m]['score']/2,  0) * 2; // round score to nearest even number

if ( \$nearest2b == \$l ) {
\$count++;
if (\$count > 1) {
\$n .= ', &nbsp;';
} elseif (strpos(\$scores[\$m]['name'], 'Record') !== false) {
\$n .= '&nbsp;<----';
} else {
\$n .= '&nbsp;';
}
\$n .= \$scores[\$m]['score'];
\$n .= '&nbsp;';
\$n .= ucwords(\$scores[\$m]['name']);
if (strpos(\$scores[\$m]['name'], 'Record') !== false) {
\$n .= '&nbsp;----';
}
}
}
\$n .= "</td>\n";
}
}
echo("\$n");
echo("</tr>\n");
}
echo('</table>');
?>

------------------------------------------------------

And here's a version that prints marks for all the rule points instead of only the even numbers, with midpoints of 5 such as 20 . . . . 25 . . . . 30).

<?php

\$scores = array(array('name'  => 'Bob',
'score' => '57.3'
),
array('name'  => 'Jill',
'score' => '52.3'
),
array('name'  => 'Jack',
'score' => '48.1'
),
array('name'  => 'Tom',
'score' => '45.1'
),
array('name'  => 'Mary',
'score' => '35.9'
),
array('name'  => 'Rick',
'score' => '35.4'
),
array('name'  => 'Don',
'score' => '27.2'
),
array('name'  => 'Sally',
'score' => '27.0'
),
array('name'  => 'Moe',
'score' => '23.3'
),
array('name'  => 'John',
'score' => '20.9'
),
array('name'  => 'Record 3 Weeks Ago',
'score' => '44.2'
),
array('name'  => 'Record Last Week',
'score' => '40.0'
),
array('name'  => 'Record 2 Weeks Ago',
'score' => '31.0'
)
);
\$high_score = (int) 0;
\$i = count(\$scores);
\$j = 0;
for(\$k = 0; \$k < \$i; \$k++) {
if(\$scores[\$j]['score'] > \$high_score) {
\$high_score = (int) \$scores[\$j]['score'];
}
\$j++;
}
\$rulerTop = substr(\$high_score, 0, 1);
\$rulerTop++;
\$rulerTop .='0';

\$scoresarray = \$scores;
foreach (\$scoresarray as \$key => \$row) {
\$score[\$key] = \$row['score'];
}
array_multisort(\$score, SORT_ASC, \$scoresarray);
\$low_score = \$scoresarray[0]['score'];
\$rulerBottom = substr(\$low_score, 0, 1);
\$rulerBottom .='0';

echo("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"font: 10pt arial\">");

for(\$l = \$rulerTop; \$l >= \$rulerBottom; \$l--) {
echo("<tr height=\"10\">\n");

if(substr(\$l, 1, 2) == '0') {
echo("<td style=\"border-right: thin solid blue\"><b>"."\$l"."</b>&nbsp;</td>\n");

}
elseif(substr(\$l, 1, 2) == '5') {
echo("<td style=\"border-right: thin solid blue\">\$l&nbsp;</td>\n");
}
else {
echo("<td valign=\"middle\" style=\"text-align:right; border-right: thin solid blue\">--</td>\n");
}

\$n = '';
\$count = 0;
for(\$m = 0; \$m < \$i; \$m++) {
\$nearest = round(\$scores[\$m]['score']);
if ( \$nearest == \$l ) {
\$n .= '<td>';

for(\$m = 0; \$m < \$i; \$m++) {
\$nearestb = round(\$scores[\$m]['score']);
if ( \$nearestb == \$l ) {
\$count++;
if (\$count > 1) {
\$n .= ', &nbsp;';
} elseif (strpos(\$scores[\$m]['name'], 'Record') !== false) {
\$n .= '&nbsp;<----';
} else {
\$n .= '&nbsp;';
}
\$n .= \$scores[\$m]['score'];
\$n .= '&nbsp;';
\$n .= ucwords(\$scores[\$m]['name']);
if (strpos(\$scores[\$m]['name'], 'Record') !== false) {
\$n .= '&nbsp;----';
}
}
}
\$n .= "</td>\n";
}
}
echo("\$n");
echo("</tr>\n");
}
echo('</table>');
?>
0

LVL 7

Accepted Solution

Very nice! That looks great and you did a great job elaborating on the example code! Im glad you got a great working version in regular html which is much more cross browser friendly than css is. I have had to do all kinds of stuff in the past to make css play friendly with every major browser so I also tend to stick to html. Well Im glad everything is working great! Funny on ruler bottom I wrote almost the identical code myself. On your example only change I made was to display 27.2 Don  |  27.0 Sally Like you asked. Anyway Im glad all is running well! Cheers!

<?php

\$scores = array(array('name'  => 'Bob',
'score' => '57.3'
),
array('name'  => 'Jill',
'score' => '52.3'
),
array('name'  => 'Jack',
'score' => '48.1'
),
array('name'  => 'Tom',
'score' => '45.1'
),
array('name'  => 'Mary',
'score' => '35.9'
),
array('name'  => 'Rick',
'score' => '35.4'
),
array('name'  => 'Don',
'score' => '27.2'
),
array('name'  => 'Sally',
'score' => '27.0'
),
array('name'  => 'Moe',
'score' => '23.3'
),
array('name'  => 'John',
'score' => '20.9'
),
array('name'  => 'Record 3 Weeks Ago',
'score' => '44.2'
),
array('name'  => 'Record Last Week',
'score' => '40.0'
),
array('name'  => 'Record 2 Weeks Ago',
'score' => '31.0'
)
);
\$high_score = (int) 0;
\$i = count(\$scores);
\$j = 0;
for(\$k = 0; \$k < \$i; \$k++) {
if(\$scores[\$j]['score'] > \$high_score) {
\$high_score = (int) \$scores[\$j]['score'];
}
\$j++;
}
\$rulerTop = substr(\$high_score, 0, 1);
\$rulerTop++;
\$rulerTop .='0';

\$scoresarray = \$scores;
foreach (\$scoresarray as \$key => \$row) {
\$score[\$key] = \$row['score'];
}
array_multisort(\$score, SORT_ASC, \$scoresarray);
\$low_score = \$scoresarray[0]['score'];
\$rulerBottom = substr(\$low_score, 0, 1);
\$rulerBottom .='0';

echo("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"font: 10pt arial\">");

for(\$l = \$rulerTop; \$l >= \$rulerBottom; \$l--) {
echo("<tr height=\"10\">\n");

if(substr(\$l, 1, 2) == '0') {
echo("<td style=\"border-right: thin solid blue\"><b>"."\$l"."</b>&nbsp;</td>\n");

}
elseif(substr(\$l, 1, 2) == '5') {
echo("<td style=\"border-right: thin solid blue\">\$l&nbsp;</td>\n");
}
else {
echo("<td valign=\"middle\" style=\"text-align:right; border-right: thin solid blue\">--</td>\n");
}

\$n = '';
\$count = 0;
for(\$m = 0; \$m < \$i; \$m++) {
\$nearest = round(\$scores[\$m]['score']);
if ( \$nearest == \$l ) {
\$n .= '<td>';

for(\$m = 0; \$m < \$i; \$m++) {
\$nearestb = round(\$scores[\$m]['score']);
if ( \$nearestb == \$l ) {
\$count++;
if (\$count > 1) {
\$n .= '&nbsp; | &nbsp;';
} elseif (strpos(\$scores[\$m]['name'], 'Record') !== false) {
\$n .= '&nbsp;<----';
} else {
\$n .= '&nbsp;';
}
\$n .= \$scores[\$m]['score'];
\$n .= '&nbsp;';
\$n .= ucwords(\$scores[\$m]['name']);
if (strpos(\$scores[\$m]['name'], 'Record') !== false) {
\$n .= '&nbsp;----';
}
}
}
\$n .= "</td>\n";
}
}
echo("\$n");
echo("</tr>\n");
}
echo('</table>');
?>
0

Author Comment

Thanks!
0

LVL 7

Expert Comment

Glad to help! Thanks for the grade & points!
0

## Write Comment

Please enter a first name

Please enter a last name

We will never share this with anyone.

## Featured Post

### Suggested Solutions

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

#### 760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

#### Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!