I just realized why this wont work
Because my db looks like this
map ----------- league ----------- date ----------- opponent
------------------------------------------------------------------
de_dust2--------cal--------2004-01-01------------clan1
de_aztec--------cal--------2004-02-02------------clan1
de_dust2--------cal--------2004-01-01------------clan5
de_cbble--------cal--------2004-01-01------------clan6
-------------------------------------------------------------------
Notice that it goes the first row.. so now pastmonth is dust2. It goes through the loop again and notices that pastmonth is different, so it makes a new row outputting aztec..
Now it looks like
Dust2
Aztec
Now it goes through the loop again notices that pastmonth is aztec and next month is dust2.. they are different so it outputs the next row. Now the output looks like this
Dust2
Aztec
Dust2
And it continues.... :S How can I get around this?
A little help plz ty <(0.o)>
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
GRR 1 more quick question.. how can I calculate the number of times the map has been passed..... so I can determine the total number of times the map has been played and will be used in other calculations. TY
Code: Select all
<?php
<? include ("mysql.php");
if ($r=="cal") {
// Preparing data from the tables
$result = @mysql_query("SELECT * FROM records_cal ORDER BY `map` ");
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
}elseif ($r=="scrim") {
// Preparing data from the tables
$result = @mysql_query("SELECT * FROM records_scrim ORDER BY `map`");
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
}
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="22"></td>
<td colspan="4"><font color="#000000" size="2">.: Some Match Stats</font></td>
</tr>
<tr>
<td height="22" background="records_top_bg2.jpg"></td>
<td height="22" background="records_top_bg2.jpg"><strong><font color="#990000" size="2" face="Arial, Helvetica, sans-serif">Map</font></strong></td>
<td height="22" background="records_top_bg2.jpg"><strong><font color="#990000" size="2" face="Arial, Helvetica, sans-serif">Total Matches Played</font></strong></td>
<td height="22" background="records_top_bg2.jpg"><strong><font color="#990000" size="2" face="Arial, Helvetica, sans-serif">% to win</font></strong></td>
</tr>
<?
$pastmap = ""; // so that the first map always gets outputted.
$de_dust2 = 0;
$de_aztec = 0;
$de_nuke = 0;
$de_train = 0;
$de_cpl_fire = 0;
$de_cpl_mill = 0;
$de_inferno = 0;
$de_cbble = 0;
$de_comrade = 0;
$de_unknown = 0;
// Setting variables from the table
while ( $row = mysql_fetch_array($result) ) {
$date = $row["date"];
$outcome = $row["outcome"];
$league = $row["league"];
$map = $row["map"];
$opponent = $row["opponent"];
$league = $row["league"];
if ($map == de_dust2) {
$de_dust2 = $de_dust2 + 1;
}elseif ($map == de_aztec) {
$de_aztec = $de_aztec + 1;
}elseif ($map == de_nuke) {
$de_nuke = $de_nuke + 1;
}elseif ($map == de_train) {
$de_train = $de_train + 1;
}elseif ($map == de_cpl_fire) {
$de_cpl_fire = $de_cpl_fire + 1;
}elseif ($map == de_cpl_mill) {
$de_cpl_mill = $de_cpl_mill + 1;
}elseif ($map == de_inferno) {
$de_inferno = $de_inferno + 1;
}elseif ($map == de_cbble) {
$de_cbble = $de_cbble + 1;
}elseif ($map == de_comrade) {
$de_comrade = $de_comrade + 1;
}elseif ($map == de_unknown) {
$de_unknown = $de_unknown + 1;
$tp_unknown = $de_unknown;
}
if ($pastmap != $map) {
echo "<tr>\n".
"<td width="4%" height="22" background="record_table_rowbg.jpg"></td>\n".
"<td width="32%" height="22" background="record_table_rowbg.jpg"><font size="2">$map</font></td>\n".
"<td width="32%" height="22" background="record_table_rowbg.jpg"><font size="2">$totalplayed</font></td>\n".
"<td width="32%" height="22" background="record_table_rowbg.jpg"><font size="2">$percent</font></td>\n".
"</tr>\n";
}
$pastmap = $map; // set the current map to the past map.
}
?>
</table>
?>