Code Comments
Programming Forum and web based access to our favorite programming groups.hey gang. have a question or 2 here.
I have a page that gets stats from an xml feed.
what i want to do is take the top 15 players stats, and display them on a
page.
now, in displaying them... i don't want them to go down the page, i want
them to go across.
the view would be 5 names across, and 3 rows for the 15 names.
any ideas??
here is my code:
<?php
$clanid="22829";
function startTag($parser, $name, $attrs) {
global $stack;
$tag=array("name"=>$name,"attrs"=>$attrs);
array_push($stack,$tag);
}
function cdata($parser, $cdata) {
global $stack;
$stack[count($stack)-1]['cdata'] .= $cdata;
}
function endTag($parser, $name) {
global $stack;
$stack[count($stack)-2]['children'][] = $stack[count($stack)-1];
array_pop($stack);
}
function aSortBySecondIndex($multiArray, $secondIndex, $dir) {
while (list($firstIndex, ) = each($multiArray))
$indexMap[$firstIndex] = $multiArray[$firstIndex][$secondIndex];
if ($dir==0)
asort($indexMap);
else
arsort($indexMap);
while (list($firstIndex, ) = each($indexMap))
if (is_numeric($firstIndex))
$sortedArray[] = $multiArray[$firstIndex];
else $sortedArray[$firstIndex] = $multiArray[$firstIndex];
return $sortedArray;
}
// Parse XML
$stack = array();
$claninfo = array();
$clanstats = array();
$playerstats = array();
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startTag", "endTag");
xml_set_character_data_handler($xml_pars
er, "cdata");
$xmllink="http://aaotracker.4players.de/livefeed/xml_clanprofile.php?clanid=
$clanid";
$data = xml_parse($xml_parser,file_get_contents(
$xmllink));
if(!$data) die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml
_parser)),
xml_get_current_line_number($xml_parser)
));
xml_parser_free($xml_parser);
// Get Player Data
for($i = 0; $i < sizeof($stack[0][children][2][children])
; $i++) {
for($x = 0; $x < sizeof($stack[0][children][2][children][
$i][children]);
$x++) {
$valname=$stack[0][children][2][children
][$i][children][$x][name];
$value=$stack[0][children][2][children][
$i][children][$x][cdata];
if($valname=="PLAYERID") $pid=$value;
$playerstats[$pid][$valname]=$value;
}
$playerstats[$pid][PLAYERFRAG]=round($pl
ayerstats[$pid][PLAYERKILLS]/$playerstats[$pid][PLAYERDEATHS],2);
}
foreach($claninfo as $key => $value) {
if ($key=="CLANSTATSURL") {
//echo "<td align=left>$key:</td> <td width=10> </td> <td
align=left><a href=$value>-={GIG}=- Clan AAO Tracker
Stats</a><br></td></tr>\n";
}
else {
//echo "<td align=left>$key:</td> <td width=10> </td> <td
align=left>$value<br></td></tr>\n";
}
}
echo "</table>";
echo "<br><br>";
// Display Clan Stats
echo "<table align=center><tr>";
foreach($clanstats as $key => $value) {
}
switch ($sort) {
default:
$playerstats_sorted=aSortBySecondIndex($
playerstats, "PLAYERHONOR", 1);
}
foreach($playerstats_sorted as $key => $value) {
$playername=$playerstats_sorted[$key][PL
AYERNAME];
$playerhonor=$playerstats_sorted[$key][P
LAYERHONOR];
$playerurl=$playerstats_sorted[$key][PLA
YERSTATSURL];
$playerkills=$playerstats_sorted[$key][P
LAYERKILLS];
$playerdeaths=$playerstats_sorted[$key][
PLAYERDEATHS];
$playerscore=$playerstats_sorted[$key][P
LAYERSCORE];
$playerfrag=$playerstats_sorted[$key][PL
AYERFRAG];
$playertime=floor(($playerstats_sorted[$
key][PLAYERTIME])/60/60);
if($playerstats_sorted[$key][PLAYERSTATU
S]=="1") $statuspic="ponline.gif";
else $statuspic="poffline.gif";
if ($playerfrag < 1.0)
$frcolor="#ff0000";
elseif ($playerfrag < 2.0)
$frcolor="#EA7500";
else
$frcolor="#00ff00";
echo "<tr>";
echo "<td align=left><font size=1>$playername - $playerhonor</font> / <font
size=1 color=$frcolor>$playerfrag</font></td></tr>";
}
echo "</table>";
?>
<body link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" text="#FFFFFF"
bgcolor="#353029">
Post Follow-up to this messageoh, by the way. not sure why there is a space between each row, but i wouldn't want that either. let me show you how it should look. now this is done with asp currently, but want the php page i gave to be included there. http://aa.gig-gamers.com/index9.asp notice the group of names at the top? that is how i want it to appear with the code i provided. any help would be most appreciated. Jeff "Jeff" <gig_bam@adelphia.net> wrote in message news:7uCdnY6KRflmucPZnZ2dnUVZ_s-dnZ2d@adelphia.com... > hey gang. have a question or 2 here. > > I have a page that gets stats from an xml feed. > what i want to do is take the top 15 players stats, and display them on a > page. > now, in displaying them... i don't want them to go down the page, i want > them to go across. > the view would be 5 names across, and 3 rows for the 15 names. > > any ideas?? > > here is my code: > > <?php > > $clanid="22829"; > > function startTag($parser, $name, $attrs) { > global $stack; > > $tag=array("name"=>$name,"attrs"=>$attrs); > array_push($stack,$tag); > } > > function cdata($parser, $cdata) { > global $stack; > > $stack[count($stack)-1]['cdata'] .= $cdata; > } > > function endTag($parser, $name) { > global $stack; > > $stack[count($stack)-2]['children'][] = $stack[count($stack)-1]; > array_pop($stack); > } > > function aSortBySecondIndex($multiArray, $secondIndex, $dir) { > while (list($firstIndex, ) = each($multiArray)) > $indexMap[$firstIndex] = $multiArray[$firstIndex][$secondIndex]; > if ($dir==0) > asort($indexMap); > else > arsort($indexMap); > while (list($firstIndex, ) = each($indexMap)) > if (is_numeric($firstIndex)) > $sortedArray[] = $multiArray[$firstIndex]; > else $sortedArray[$firstIndex] = $multiArray[$firstIndex]; > return $sortedArray; > } > > // Parse XML > > $stack = array(); > $claninfo = array(); > $clanstats = array(); > $playerstats = array(); > > $xml_parser = xml_parser_create(); > xml_set_element_handler($xml_parser, "startTag", "endTag"); > xml_set_character_data_handler($xml_pars er, "cdata"); > > $xmllink="http://aaotracker.4players.de/livefeed/xml_clanprofile.php?clani d=$clanid"; > $data = xml_parse($xml_parser,file_get_contents( $xmllink)); > if(!$data) die(sprintf("XML error: %s at line %d", > xml_error_string(xml_get_error_code($xml _parser)), > xml_get_current_line_number($xml_parser) )); > > xml_parser_free($xml_parser); > > > > > // Get Player Data > for($i = 0; $i < sizeof($stack[0][children][2][children]) ; $i++) { > for($x = 0; $x < sizeof($stack[0][children][2][children][ $i][children]); > $x++) { > $valname=$stack[0][children][2][children ][$i][children][$x][name]; > $value=$stack[0][children][2][children][ $i][children][$x][cdata]; > if($valname=="PLAYERID") $pid=$value; > $playerstats[$pid][$valname]=$value; > } > > $playerstats[$pid][PLAYERFRAG]=round($pl ayerstats[$pid][PLAYERKILLS]/$playerstats[$pid][PLAYERDEATHS],2); > } > > foreach($claninfo as $key => $value) { > if ($key=="CLANSTATSURL") { > //echo "<td align=left>$key:</td> <td width=10> </td> <td > align=left><a href=$value>-={GIG}=- Clan AAO Tracker > Stats</a><br></td></tr>\n"; > } > else { > //echo "<td align=left>$key:</td> <td width=10> </td> <td > align=left>$value<br></td></tr>\n"; > } > } > echo "</table>"; > > echo "<br><br>"; > > // Display Clan Stats > echo "<table align=center><tr>"; > > foreach($clanstats as $key => $value) { > > } > > switch ($sort) { > > default: > $playerstats_sorted=aSortBySecondIndex($ playerstats, "PLAYERHONOR", 1); > } > > foreach($playerstats_sorted as $key => $value) { > $playername=$playerstats_sorted[$key][PL AYERNAME]; > $playerhonor=$playerstats_sorted[$key][P LAYERHONOR]; > $playerurl=$playerstats_sorted[$key][PLA YERSTATSURL]; > $playerkills=$playerstats_sorted[$key][P LAYERKILLS]; > $playerdeaths=$playerstats_sorted[$key][ PLAYERDEATHS]; > $playerscore=$playerstats_sorted[$key][P LAYERSCORE]; > $playerfrag=$playerstats_sorted[$key][PL AYERFRAG]; > $playertime=floor(($playerstats_sorted[$ key][PLAYERTIME])/60/60); > > if($playerstats_sorted[$key][PLAYERSTATU S]=="1") $statuspic="ponline.gif"; > else $statuspic="poffline.gif"; > > if ($playerfrag < 1.0) > $frcolor="#ff0000"; > elseif ($playerfrag < 2.0) > $frcolor="#EA7500"; > else > $frcolor="#00ff00"; > > echo "<tr>"; > echo "<td align=left><font size=1>$playername - $playerhonor</font> / > <font size=1 color=$frcolor>$playerfrag</font></td></tr>"; > > } > echo "</table>"; > > ?> > <body link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" text="#FFFFFF" > bgcolor="#353029"> >
Post Follow-up to this messageJeff wrote:
> now, in displaying them... i don't want them to go down the page, i
> want
> them to go across.
> the view would be 5 names across, and 3 rows for the 15 names.
First: clean up your code, it's loaded with expressions you don't even
use...
Further: basic HTML?
$i = 0;
> foreach($playerstats_sorted as $key => $value) {
if($i==0){ echo '<tr>';}
> echo "<td align=left><font size=1>$playername - $playerhonor</font>
> / <font
> size=1 color=$frcolor>$playerfrag</font></td>";
if($i==4){
echo '</tr>';
$i = 0;
} else{
$i++;
}
}
And about your HTML: it's always wise to quote the attributes, so:
align="left" instead of align=left etc...
Also consider using css instead. Keeps it readable, easily editable.
Grtz,
--
Rik Wasmus
Post Follow-up to this messagethanks for the help. The extra stuff is because this feed contained a bunch more stuff. I didn't delete alot because i wasn't sure if it was needed. I am an asp guy trying to learn php. so i wasn't sure how to put html into php code either. now on the the code. i made the changes that you put there (i think), and it still goes verticle. http://aa.gig-gamers.com/Clanstats/index3.php posting my "new" code here: <?php $clanid="22829"; function startTag($parser, $name, $attrs) { global $stack; $tag=array("name"=>$name,"attrs"=>$attrs); array_push($stack,$tag); } function cdata($parser, $cdata) { global $stack; $stack[count($stack)-1]['cdata'] .= $cdata; } function endTag($parser, $name) { global $stack; $stack[count($stack)-2]['children'][] = $stack[count($stack)-1]; array_pop($stack); } function aSortBySecondIndex($multiArray, $secondIndex, $dir) { while (list($firstIndex, ) = each($multiArray)) $indexMap[$firstIndex] = $multiArray[$firstIndex][$secondIndex]; if ($dir==0) asort($indexMap); else arsort($indexMap); while (list($firstIndex, ) = each($indexMap)) if (is_numeric($firstIndex)) $sortedArray[] = $multiArray[$firstIndex]; else $sortedArray[$firstIndex] = $multiArray[$firstIndex]; return $sortedArray; } // Parse XML $stack = array(); $claninfo = array(); $clanstats = array(); $playerstats = array(); $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startTag", "endTag"); xml_set_character_data_handler($xml_pars er, "cdata"); $xmllink="http://aaotracker.4players.de/livefeed/xml_clanprofile.php?clanid= $clanid"; $data = xml_parse($xml_parser,file_get_contents( $xmllink)); if(!$data) die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml _parser)), xml_get_current_line_number($xml_parser) )); xml_parser_free($xml_parser); // Get Player Data for($i = 0; $i < sizeof($stack[0][children][2][children]) ; $i++) { for($x = 0; $x < sizeof($stack[0][children][2][children][ $i][children]); $x++) { $valname=$stack[0][children][2][children ][$i][children][$x][name]; $value=$stack[0][children][2][children][ $i][children][$x][cdata]; if($valname=="PLAYERID") $pid=$value; $playerstats[$pid][$valname]=$value; } $playerstats[$pid][PLAYERFRAG]=round($pl ayerstats[$pid][PLAYERKILLS]/$playerstats[$pid][PLAYERDEATHS],2); } foreach($claninfo as $key => $value) { if ($key=="CLANSTATSURL") { //echo "<td align=left>$key:</td> <td width=10> </td> <td align=left><a href=$value>-={GIG}=- Clan AAO Tracker Stats</a><br></td></tr>\n"; } else { //echo "<td align=left>$key:</td> <td width=10> </td> <td align=left>$value<br></td></tr>\n"; } } echo "</table>"; echo "<br><br>"; // Display Clan Stats echo "<table align=center><tr>"; foreach($clanstats as $key => $value) { } switch ($sort) { default: $playerstats_sorted=aSortBySecondIndex($ playerstats, "PLAYERHONOR", 1); } $i = 0; foreach($playerstats_sorted as $key => $value) { if($i==0){ echo '<tr>';} $playername=$playerstats_sorted[$key][PL AYERNAME]; $playerhonor=$playerstats_sorted[$key][P LAYERHONOR]; $playerurl=$playerstats_sorted[$key][PLA YERSTATSURL]; $playerkills=$playerstats_sorted[$key][P LAYERKILLS]; $playerdeaths=$playerstats_sorted[$key][ PLAYERDEATHS]; $playerscore=$playerstats_sorted[$key][P LAYERSCORE]; $playerfrag=$playerstats_sorted[$key][PL AYERFRAG]; $playertime=floor(($playerstats_sorted[$ key][PLAYERTIME])/60/60); if($playerstats_sorted[$key][PLAYERSTATU S]=="1") $statuspic="ponline.gif"; else $statuspic="poffline.gif"; if ($playerfrag < 1.0) $frcolor="#ff0000"; elseif ($playerfrag < 2.0) $frcolor="#EA7500"; else $frcolor="#00ff00"; echo "<tr>"; echo "<td align=left><font size=1>$playername - $playerhonor</font> / <font size=1 color=$frcolor>$playerfrag</font></td></tr>"; if($i==4){ echo '</tr>'; $i = 0; } else{ $i++; } } echo "</table>"; ?> thanks again for helping me "Rik" <luiheidsgoeroe@hotmail.com> wrote in message news:e3l9f1$qoe$1@netlx020.civ.utwente.nl... > Jeff wrote: > > First: clean up your code, it's loaded with expressions you don't even > use... > Further: basic HTML? > > $i = 0; > > > if($i==0){ echo '<tr>';} > > > if($i==4){ > echo '</tr>'; > $i = 0; > } else{ > $i++; > } > } > > And about your HTML: it's always wise to quote the attributes, so: > align="left" instead of align=left etc... > Also consider using css instead. Keeps it readable, easily editable. > > Grtz, > -- > Rik Wasmus > >
Post Follow-up to this messageI took more code out.
also. is there going to be a way to base this on the top 15 $playerhonor??
and only display those??
NEW CODE:
<?php
$clanid="22829";
function startTag($parser, $name, $attrs) {
global $stack;
$tag=array("name"=>$name,"attrs"=>$attrs);
array_push($stack,$tag);
}
function cdata($parser, $cdata) {
global $stack;
$stack[count($stack)-1]['cdata'] .= $cdata;
}
function endTag($parser, $name) {
global $stack;
$stack[count($stack)-2]['children'][] = $stack[count($stack)-1];
array_pop($stack);
}
function aSortBySecondIndex($multiArray, $secondIndex, $dir) {
while (list($firstIndex, ) = each($multiArray))
$indexMap[$firstIndex] = $multiArray[$firstIndex][$secondIndex];
if ($dir==0)
asort($indexMap);
else
arsort($indexMap);
while (list($firstIndex, ) = each($indexMap))
if (is_numeric($firstIndex))
$sortedArray[] = $multiArray[$firstIndex];
else $sortedArray[$firstIndex] = $multiArray[$firstIndex];
return $sortedArray;
}
// Parse XML
$stack = array();
$claninfo = array();
$clanstats = array();
$playerstats = array();
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startTag", "endTag");
xml_set_character_data_handler($xml_pars
er, "cdata");
$xmllink="http://aaotracker.4players.de/livefeed/xml_clanprofile.php?clanid=
$clanid";
$data = xml_parse($xml_parser,file_get_contents(
$xmllink));
if(!$data) die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml
_parser)),
xml_get_current_line_number($xml_parser)
));
xml_parser_free($xml_parser);
// Get Player Data
for($i = 0; $i < sizeof($stack[0][children][2][children])
; $i++) {
for($x = 0; $x < sizeof($stack[0][children][2][children][
$i][children]);
$x++) {
$valname=$stack[0][children][2][children
][$i][children][$x][name];
$value=$stack[0][children][2][children][
$i][children][$x][cdata];
if($valname=="PLAYERID") $pid=$value;
$playerstats[$pid][$valname]=$value;
}
$playerstats[$pid][PLAYERFRAG]=round($pl
ayerstats[$pid][PLAYERKILLS]/$playerstats[$pid][PLAYERDEATHS],2);
}
echo "<br><br>";
echo "<table align=center><tr>";
switch ($sort) {
default:
$playerstats_sorted=aSortBySecondIndex($
playerstats, "PLAYERHONOR", 1);
}
$i = 0;
foreach($playerstats_sorted as $key => $value) {
if($i==0){ echo '<tr>';}
$playername=$playerstats_sorted[$key][PL
AYERNAME];
$playerhonor=$playerstats_sorted[$key][P
LAYERHONOR];
$playerurl=$playerstats_sorted[$key][PLA
YERSTATSURL];
$playerkills=$playerstats_sorted[$key][P
LAYERKILLS];
$playerdeaths=$playerstats_sorted[$key][
PLAYERDEATHS];
$playerscore=$playerstats_sorted[$key][P
LAYERSCORE];
$playerfrag=$playerstats_sorted[$key][PL
AYERFRAG];
$playertime=floor(($playerstats_sorted[$
key][PLAYERTIME])/60/60);
if($playerstats_sorted[$key][PLAYERSTATU
S]=="1") $statuspic="ponline.gif";
else $statuspic="poffline.gif";
if ($playerfrag < 1.0)
$frcolor="#ff0000";
elseif ($playerfrag < 2.0)
$frcolor="#EA7500";
else
$frcolor="#00ff00";
echo "<tr>";
echo "<td align=left><font size=1>$playername - $playerhonor</font> / <font
size=1 color=$frcolor>$playerfrag</font></td></tr>";
if($i==4){
echo '</tr>';
$i = 0;
} else{
$i++;
}
}
echo "</table>";
?>
<body link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" text="#FFFFFF"
bgcolor="#353029">
"Rik" <luiheidsgoeroe@hotmail.com> wrote in message
news:e3l9f1$qoe$1@netlx020.civ.utwente.nl...
> Jeff wrote:
>
> First: clean up your code, it's loaded with expressions you don't even
> use...
> Further: basic HTML?
>
> $i = 0;
>
>
> if($i==0){ echo '<tr>';}
>
>
> if($i==4){
> echo '</tr>';
> $i = 0;
> } else{
> $i++;
> }
> }
>
> And about your HTML: it's always wise to quote the attributes, so:
> align="left" instead of align=left etc...
> Also consider using css instead. Keeps it readable, easily editable.
>
> Grtz,
> --
> Rik Wasmus
>
>
Post Follow-up to this messageJeff wrote: > now on the the code. i made the changes that you put there (i think), > and it > still goes verticle. That's because you haven't implemented the code I gave you.... You echo: > echo "<td align=left><font size=1>$playername - $playerhonor</font> / <font> size=1 color=$frcolor>$playerfrag</font></td></tr>"; I said: <font size=1 color=$frcolor>$playerfrag</font></td>"; Notice I don't start a row before and terminate the row after EACH player... Grtz, -- Rik Wasmus
Post Follow-up to this messagei am sorry. it must be a blonde day. i am not following what you mean there. "Rik" <luiheidsgoeroe@hotmail.com> wrote in message news:e3larv$u3e$1@netlx020.civ.utwente.nl... > Jeff wrote: > > That's because you haven't implemented the code I gave you.... > > You echo: > <font> size=1 color=$frcolor>$playerfrag</font></td></tr>"; > > > I said: > <font size=1 color=$frcolor>$playerfrag</font></td>"; > > Notice I don't start a row before and terminate the row after EACH > player... > > Grtz, > -- > Rik Wasmus > >
Post Follow-up to this messageJeff wrote:
> I took more code out.
> also. is there going to be a way to base this on the top 15
> $playerhonor??
> and only display those??
> switch ($sort) {
>
> default:
> $playerstats_sorted=aSortBySecondIndex($
playerstats, "PLAYERHONOR",
> 1); }
> $i = 0;
//assuming aSortBySecondIndex() works:
$player_stats_sorted = array_slice($player_stats_sorted,0,14);
foreach($playerstats_sorted as $value) {
if($i==0){ echo '<tr>';}
if($value['PLAYERSTATUS']=="1") $statuspic="ponline.gif"; else
$statuspic="poffline.gif";
if ($value['PLAYERFRAG'] < 1.0){
$frcolor="#ff0000";
} elseif ($value['PLAYERFRAG'] < 2.0){
$frcolor="#EA7500";
} else{
$frcolor="#00ff00";
}
REMOVE THE FOLLOWING 1 LINE!!
> echo "<tr>";
printf("<td style=\"text-align:left;font-size:1em;\">%s - %d / <span
style=\"color:$frcolor;\">%01.2f</span></td>", $value['PLAYERNAME'],
$value['PLAYERHONOR'],$value['PLAYERFRAG
']);
if($i==4){
echo '</tr>';
$i = 0;
} else{
$i++;
}
}
Grtz,
--
Rik Wasmus
Post Follow-up to this messageI should pay you? I have been to many NG's here. And you have answered my question either very poorly, or very differently than anyone else has answered other questions from other users and myself. If you are here to help, then help. Explain what you are doing as if I don't know (because if I did know, I wouldn't have posted) I will shelp else where, but thanks anyway. "Rik" <luiheidsgoeroe@hotmail.com> wrote in message news:e3lf3o$7nn$1@netlx020.civ.utwente.nl... > Jeff wrote: > > I SHOULD? > You should pay me :-) > > > Oh, OK > > http://www.php.net/ > http://www.w3schools.com/ > > All you need to know. > Man, had I known that that was all there was needed I would have anwered > every question in this newsgroup. > > Grtz, > -- > Rik Wasmus > >
Post Follow-up to this messageJeff wrote: > I should pay you? I have been to many NG's here. And you have > answered my question either very poorly, I've practically given you a working script.... > or very differently than > anyone else has answered other questions from other users and myself. > If you are here to help, then help. Explain what you are doing as if > I don't know (because if I did know, I wouldn't have posted) If I introduce a function that you aren't familiar with, I expect you have the sense to lookup that function. Surprised? That's how I learned. If people gave me code, and it didn't work, I would look at the PHP manual, figure out what they were trying to do, and after that, get back to them. If you have a foreach() in your scipt, and it doesn't work and you don't know what it does, I expect you to try to find out what it does. If you make a webpage, I assume you know how a table is constructed in HTML. Surprised? I was, after learning that "Notice I don't start a row before and terminate the row after EACH player..." was total gibberish to you. I was even kind enough to point to how tables were created in case you didn't. Futhermore, my statement about writing code yourself that people more experienced could write in a heartbeat for you to copy/paste is IMHO true for everybody: trying to code it yourself, allthough it's done many a times, and often better, is great for learning. In my opinion, I stood by you longer than most people would have. I could have told you "array_slice" and leave you figuring it out for yourself, but no, I was in a helping mood, and thought to give some more specific code. Might have been better for you. Realizing you didn't understand i wrote more and more code for you, which you pasted into your script without thinking, and instead of figuring out why it didn't work you came back and nagged about it. Newsgroups aren't meant to be your personal helpdesk, you're supposed to try to figure things out for yourself, researching it in manuals and online. After that, you ask your question, and hopefully get an answer. If you get an answer, you don't just copy/paste it. You try to understand what it is exactly what it's doing, do your research over again, guided by the answer. If something doesn't work, isolate the part of the code that doesn't work by trying the different pieces seperately. If it's about output, don't look at the page, look at the source of the page. Then, and only then, if things still aren't clear to you, come back to the ng, and tell the people which part of your code still doesn't work. Don't demand they do stuff for you, ask them. > I will shelp else where, but thanks anyway. www.php.net Learn, realise I've given you a perfect script in a few w
s, and I'll be waiting for you apology. Once again (the only thing missing are opening and closign <table>-tags: $player_stats_sorted = array_slice($player_stats_sorted,0,14); $i=0; foreach($playerstats_sorted as $value) { if($i==0){ echo '<tr>';} if($value['PLAYERSTATUS']=="1") {$statuspic="ponline.gif";} else{ $statuspic="poffline.gif";} if ($value['PLAYERFRAG'] < 1.0){ $frcolor="#ff0000"; } elseif ($value['PLAYERFRAG'] < 2.0){ $frcolor="#EA7500"; } else{ $frcolor="#00ff00"; } printf("<td style=\"text-align:left;font-size:1em;\">%s - %d / <span style=\"color:$frcolor;\">%01.2f</span></td>", $value['PLAYERNAME'], $value['PLAYERHONOR'],$value['PLAYERFRAG ']); if($i==4){ echo '</tr>'; $i = 0; } else{ $i++; } } Grtz, -- Rik Wasmus
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.