-3

Possible Duplicate:
sorting php data var problem

This should be pretty easy to follow looking at my code, but my code still isn't working. Could someone please just tweak this until it works? I'm at my breaking point and feel a full blown code-induced breakdown coming on!

I want to sort the data by player number, and then the person with the highest point should have their whole row colored red:

file1.php

 <!doctype html public "-//W3C//DTD HTML 4.0 //EN"> 
 <html> 
 <head> 
 <title>Fantasy Football</title> 
 </head> 
 <body> 
 <form action="roster.php" method="POST"> 
 <table border="1"> 
 <tr><td>Player Name</td><td><input type="text" name="name"</td></tr> 
 <tr><td>Position</td><td><input type="text" name="position"</td></tr> 
 <tr><td>Number</td><td><input type="text" name="number"</td></tr> 
 <tr><td>Team</td><td><input type="text" name="team"</td></tr> 
 <tr><td>Points per game</td><td><input type="text" name="points"</td></tr> 
 <tr><td colspan="2" align="center"><input type="submit"></td></tr> 
 </table> 
 </form> 
 </body> 
 </html> 

roster.php

 <?php 
 for($i = 0; $i < sizeof($players); $i++) { 
 list($name[],$team[],$number[],$position[],$points[]) = explode('|', $players[$i]); 
 } 
 array_multisort($number, $position, $name, $team, $points, SORT_DESC); 
 $mostPoints = max($points); 
 for($i = 0; $i < sizeof($players); $i++) { 
 if($points[$i]==mostPoints){ 
 echo '<tr style="background:#F44">'; 
 }else{ 
 echo '<tr>'; 
 } 
 echo '<td>'.$name[$i].'</td><td>'.$team[$i].'</td><td>'.$number[$i].'</td> 
 <td>'.$position  [$i].'</td><td>'.$points[$i].'</td></tr>'; 
 } 

 ?> 

When I run this, it like it can't access the data in the txt file. WHAT AM I MISSING?

3
  • You still have not removed the var that I mentioned in your previous exact question. Commented Jul 13, 2011 at 2:07
  • i did change the var and i reposted because i wasn't getting any more help in my old post... Commented Jul 13, 2011 at 2:09
  • Duplicates are frowned upon here, therefore asking the same question is too. Commented Jul 13, 2011 at 2:22

1 Answer 1

0

Seems like you've just started programming.

Don't mind the difficulties you face at the beginning.

Regarding your code, you could achieve client-side (without using PHP) the same functionality, but it will take a bit more study from you (learning Jquery, javascript and a few CSS tricks).

Check this example, you could follow from here: http://jsfiddle.net/F6ezD/28/

It orders the table on-the-fly as you enter the players. Unfortunately I haven't had time to code the max score table highlight. Perhaps you could take that as a challenge and go from here ?

A key change to programming these times is that someone in the net already coded something you need, such as the sorting function I used on the fiddle example.

Good luck!

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.