Page 1 of 1

loop question

Posted: Wed May 12, 2004 2:10 pm
by speedamp
hello everybody,

I have written the following loop that works realy great. What it does is allows a user to input results and this program will then loop through and allot points and an overall order.

My question is that what i need to do it combine many of these loops into one program and then output and sort the final points.

points (as you can see in the code) are allotted by an equation that relies upon the place and number of entries (which are not constants)

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

Code: Select all

$run_query = "SELECT * FROM ....WHERE sex = 'male' and one_time > 0 order by one_time"; 
$run_result = mysql_query($run_query); 
$numrows = mysql_numrows($run_result); 
$i=1; 
while($run_row = mysql_fetch_array($run_result)){ 
$mydataorder = $run_row[user] + $i; 
$mydatafirst = $run_row['first_name']; 
$mydatalast = $run_row['last_name']; 
$mydataage = $run_row['age']; 
$mydataplace = $run_row['one_place']; 
$mydatateam = $run_row['team']; 
$mydataoneplace = $run_row['one_time']; 
$mydataonepoints = ROUND(1000-($mydataorder-1)*(1000/$numrows)); 
echo "<tr><td>".$mydataorder."</td><td>".$mydataplace."</td><td>".$mydatafirst. "&nbsp" .$mydatalast."</td><td>".$mydataage."</td><td>".$mydatateam."</td><td>".$mydataoneplace."</td><td>".$mydataonepoints."</td></tr>"; 
$i++; 
}
-------------------------------------------------------------------------

for example, i now have event TWO, and i change all the loops to show event two....how can i combine these two and have an OVERALL POINTS field.

[ .:Edit patrikG:

Code: Select all

-tags added to bring out the bright metallic rainbow colours of your code... next time you know how to do it yourself. :. ]

-mike

Posted: Wed May 12, 2004 2:42 pm
by xisle
how's this for an :idea:
Try creating an 'event' table relational to the
runner/person/whatever table. Then you can query all
events at one time and need only one loop to
display the results...