Jump to content

[SOLVED] Organizing results


uramagget

Recommended Posts

$players = $mysql->select(
					"ndsg_brawl.tourneys_brackets",
					"*",
					"WHERE tourney = '{$title}'"
					);

					if ($players)
					{
						while ($pairings = @mysql_fetch_assoc($players))
						{
							echo '
								<h2>Round '.$pairings['round'].'</h2>
							<table class="list">
								<thead>
									<tr>
										<td>User #1</td>
										<td>User #2</td>
										<td>Round</td>
									</tr>
								</thead><tbody>';
							$username1 = $mysql->select(
							"ndsg_vbulletin.vb_user",
							"username",
							"WHERE userid = '{$pairings['userid']}'"
							);
							$username2 = $mysql->select(
							"ndsg_vbulletin.vb_user",
							"username",
							"WHERE userid = '{$pairings['userid2']}'"
							);

							$username1 = @mysql_fetch_assoc($username1);
							$username2 = @mysql_fetch_assoc($username2);

							echo '<tr>
							<td>'.$username1['username'].'</td>
							<td>'.$username2['username'].'</td>
							<td>'.$pairings['round'].'</td>
							</tr>';
							echo '</tbody></table>';
						}
					}
					else
					{
						echo '<p>There are no standings up yet.</p>';
					}

 

I am not sure how to have it only display 1 table for each round. I tried using GROUP BY `round`, but it only displays 1 pairing instead of all. :/

Link to comment
https://forums.phpfreaks.com/topic/115734-solved-organizing-results/
Share on other sites

am not sure if am gettin what you are trying to achieve but you can try this:

 

SELECT GROUP_CONCAT(userid) userid1,

GROUP_CONCAT(userid2) userid2

FROM ndsg_brawl.tourneys_brackets

WHERE tourney = 'brawlan'

GROUP BY round

 

with this, each userid is delimited with comma by default otherwise specified.

now this works... but the problem is that it might be slower and pairing... so you might also try,

 

SELECT GROUP_CONCAT(userid, userid2) userids

FROM ndsg_brawl.tourneys_brackets

WHERE tourney = 'brawlan'

GROUP BY round

 

with this, userid and userid2 is delimited with space by default where each pairing is delimited with comma.

 

now, if you want to change the delimiter for userid and userid2, you may try CONCAT() for additional mods.

 

did I answer you question?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.