Jump to content

Leage table help - Probably simple


Pythondesigns

Recommended Posts

Ok,

Im coding a league system... Each league can have multiple divisions.

Here are three tables...

leagues(id, name);

divisions(id, leagueID);

scores(id, leagueID, userID, score);

For this example lets assume that there is one league, three divisions within that league and 20 rows in the scores table.

I want to loop through and display a table for each division.

I want to order the scores table by the score field ASC. Then display them in the divisions (10 per divisions).

So in division one it has the top 10 scores.
In division two the 11-20 top scores
In division three 21-30 top scores.


Can you help me.

Thanks
Link to comment
Share on other sites

  • 2 weeks later...
Something like this??

[code]<?php

$query1 = "SELECT id FROM `leagues`";
$result1 = mysql_query($query1);

while($league = mysql_fetch_array($result1))
{
$query2 = "SELECT COUNT(*) AS num FROM `divisions`";
$result2 = mysql_query($query2);
$division = mysql_fetch_array($result2);
$tables = $division['num'];

$i = 0;
while($i < $tables)
{
$query3 = "SELECT * FROM `scores` ORDER BY score LIMIT ".$i.","($i+10);
$result3 = mysql_query($query3);
echo "<table><tr><td>id</td><td>score</td></tr>\n";

while($row = mysql_fetch_array($result3))
{
echo "<tr>";
echo "<td>".$row['id']."</td>";
echo "<td>".$row['score']."</td>";
echo "</tr>";
}

echo "</table><br><br>";

$i = $i + 10;
}
}

?>[/code]

Orio.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.