Variable won't repeat in repeat region
Posted: Wed Apr 01, 2009 8:21 am
Hello all,
I am a PHP beginner and having a problem getting a variable to assign itself to it's individual row in a repeat region:
Here's my code:
mysql_select_db($database_edr_con, $edr_con);
$query_rs_teams = "SELECT * FROM info ORDER BY win DESC";
$rs_teams = mysql_query($query_rs_teams, $edr_con) or die(mysql_error());
$row_rs_teams = mysql_fetch_assoc($rs_teams);
$totalRows_rs_teams = mysql_num_rows($rs_teams);
$pct = $row_rs_teams['win']/($row_rs_teams['win']+$row_rs_teams['loss']);
When I place $pct in my repeat region - it correctly does the math, but then just repeats the answer for the 1st row in the table, rather than giving a different answer for each row.
Here's my code as it is placed in the repeat region:
<td width="164" class="stand_row_left"><?php echo $row_rs_teams['team_name']; ?></td>
<td width="30" class="stand_row"><?php echo $row_rs_teams['win']; ?></td>
<td width="30" class="stand_row"><?php echo $row_rs_teams['loss']; ?></td>
<td width="60" class="stand_row"><?php echo $pct = number_format($pct,3); ?></td>
Can anyone tell me what I am doing wrong here in not getting my variable to identify with each individual row? All of the other values in my repeat region are working properly.
Any help is GREATLY appreciated!
I am a PHP beginner and having a problem getting a variable to assign itself to it's individual row in a repeat region:
Here's my code:
mysql_select_db($database_edr_con, $edr_con);
$query_rs_teams = "SELECT * FROM info ORDER BY win DESC";
$rs_teams = mysql_query($query_rs_teams, $edr_con) or die(mysql_error());
$row_rs_teams = mysql_fetch_assoc($rs_teams);
$totalRows_rs_teams = mysql_num_rows($rs_teams);
$pct = $row_rs_teams['win']/($row_rs_teams['win']+$row_rs_teams['loss']);
When I place $pct in my repeat region - it correctly does the math, but then just repeats the answer for the 1st row in the table, rather than giving a different answer for each row.
Here's my code as it is placed in the repeat region:
<td width="164" class="stand_row_left"><?php echo $row_rs_teams['team_name']; ?></td>
<td width="30" class="stand_row"><?php echo $row_rs_teams['win']; ?></td>
<td width="30" class="stand_row"><?php echo $row_rs_teams['loss']; ?></td>
<td width="60" class="stand_row"><?php echo $pct = number_format($pct,3); ?></td>
Can anyone tell me what I am doing wrong here in not getting my variable to identify with each individual row? All of the other values in my repeat region are working properly.
Any help is GREATLY appreciated!