Name is assigned by $name
If the greatest number is under 10 it is assigned 1
If it’s under 20 its 2
and 30 is 3
Error on line 7 for invalid arg
rest will output 3s but no $name
I doubt either is right, anyone
mind pointing me in the right direction?
sample xml
[code]
<document>
<row>
<Col0></Col0 >
<Col1>Anthony Shetler</Col1 >
<Col2>-</Col2 >
<Col3></Col3 >
<Col4>-</Col4 >
<Col5></Col5 >
<Col6>-</Col6 >
<Col7></Col7 >
</row>
<row>
<Col0></Col0 >
<Col1>Anthony Van Engelen</Col1 >
<Col2>-</Col2 >
<Col3></Col3 >
<Col4>-</Col4 >
<Col5></Col5 >
<Col6>135</Col6 >
<Col7>http://www./catalog/product/view/id/106494/category/1352/</Col7 >
</row>
<row>
<Col0></Col0 >
<Col1>Antwuan Dixon</Col1 >
<Col2>-</Col2 >
<Col3></Col3 >
<Col4>186</Col4 >
<Col5>http://couchtour./aurora_sched.htm?utm_source=zumiez&utm_medium=zumiez&utm_content=event-schedule&utm_campaign=ct-video-event-schedule</Col5 >
<Col6>163</Col6 >
<Col7>http://www./catalog/product/view/id/33367</Col7 >
</row>
<row>
<Col0></Col0 >
<Col1>Arto Saari</Col1 >
<Col2>-</Col2 >
<Col3></Col3 >
<Col4>-</Col4 >
<Col5></Col5 >
<Col6>-</Col6 >
<Col7></Col7 >
</row>
</document>
php
[code=php]
<?php
$file = ‘1.xml’;
if (file_exists($file)) {
$sxml = simplexml_load_file($file);
foreach ($xml->document->row as $x){
$name = (string)$x->col1;
$x = (string)$x->col2;
$y = (string)$x->col4;
$z = (string)$x->col6;
$$maxValue=max($x,max($y,$z));
$rank=NULL; // blank the rank
if($maxValue <= ’10’){ $rank=’1′; }
if($maxValue <= ’20’){ $rank=’2′; }
if($maxValue <= ’30’){ $rank=’3′; }
if($maxValue > ’31’) { $rank=’0′; }
$name = (string)$name;
$rank = (string)$rank;
echo “$name is $rank<br />”;
}
} else {
exit(‘Failed to open $file.’);
}
?>