grlayouts Posted November 7, 2010 Share Posted November 7, 2010 Hey, i have a script in my game that picks up the output rate of a unit which if there is more than one unit it devides, i have 3 teams and the script picks up team 1 and 2, but any units in team 3 the rate shows 0? IE HEAVY SOLDIER 100% but with the 3rd team its always showing 0% <font face="Verdana" color="#000000" size="2"><b>Output Rate</b></font></td></tr>'; $sql = "SELECT id,name FROM units WHERE class={$row[0]} AND visible=1"; $r2 = mysql_query($sql); while ($row2 = mysql_fetch_row($r2)) { echo '<tr><td align="center">'.$row2[1].'</td><td align="center"><input text="text" size="5" style="'.$boxStyle.'" name="a'.$row2[0].'" value='.getRate($userid,$row2[0]).'>%</td></tr>'; } echo '<tr><td colspan="2" align="center"><input type="submit" value="Set Rates for '.$row[1].'"></td></tr>'; echo '</table></form>'; } echo '</center>'; DB's FOR UNITS. id name toground toair hp class evolvesto style cost visible 6 Mulanix 10 10 200 3 0 1 20 1 5 Numani 5 5 100 3 6 1 10 1 any help would be great it's annoying me and i can't solve it. Quote Link to comment https://forums.phpfreaks.com/topic/218015-database-problem/ Share on other sites More sharing options...
grlayouts Posted November 8, 2010 Author Share Posted November 8, 2010 Working on it all day now and still no further forward it's only the 3rd team that doesnt show any percent at all and i don't see what im missing. i've attached the whole build file <?php if ($sc == "") { echo gloss("title", $teamid) .', Welcome to your <B>' . gloss("barracks",$teamid) . '</B>! This is where you control how much of each type of unit your army produces per turn spent.'; echo '<BR><BR>'; diver ("Construct Unit Buildings"); echo ' You may build several structures, each structure will then produce certain units of that class every time you spend a turn. To learn what type of units each structure produces and how much, scroll to the building output rate section below. The cost for constructing buildings is <B>1 turn per building</B>.'; $sql = "SELECT id,building,name FROM classes WHERE team={$teamid}"; $r = mysql_query($sql) or die (mysql_error()); echo '<form method="post" action="index.php?cmd=build&sc=do">'; echo '<center><table border="0" width="400" bordercolorlight="#808080" bordercolordark="#808080" style="border-collapse: collapse; font-family: Verdana; font-size: 12px" cellspacing="2" cellpadding="2">'; echo '<tr><td bgcolor="#C0C0C0" align="center"><font face="Verdana" color="#000000" size="2"><b>Building</b></font></td><td bgcolor="#C0C0C0" align="center"><font face="Verdana" color="#000000" size="2"><b>You Have</b></font></td><td bgcolor="#C0C0C0" align="center"><b><font face="Verdana" color="#000000" size="2">Build Amount</font></b></td></tr>'; while ($row = mysql_fetch_row($r)) { echo '<tr><td><font color="#FFFFFF"><B>'.$row[1].'</B><BR><font size="1">Produces: <B>'.$row[2].'</B></font></font></td>'; echo '<td align="center">'.number_format(getBuildCount($userid,$row[0])).'</td>'; echo '<td align="center"><input type="text" name="a'.$row[0].'" size="10" style="'.$boxStyle.'" value="0"></td></tr>'; } echo '<tr><td colspan="3" align=center><input type="submit" value="Construct"></td></tr>'; echo '</table></center></form>'; diver ("Building Output Rates"); echo "From here, you can control how much of each type of unit your buildings make, each building must add up to 100% output.<BR>"; $sql = "SELECT id,building FROM classes WHERE team={$teamid}"; $r = mysql_query($sql) or die (mysql_error()); echo '<center>'; while ($row = mysql_fetch_row($r)) { echo '<form method="post" action="index.php?cmd=build&sc=rate&bid='.$row[0].'">'; echo '<table border="0" width="300" bordercolorlight="#808080" bordercolordark="#808080" style="border-collapse: collapse; font-family: Verdana; font-size: 12px" cellspacing="2" cellpadding="2">'; echo '<tr><td bgcolor="#C0C0C0" align="center"><font face="Verdana" color="#000000" size="2"><b>'.$row[1].' units</b></font></td><td bgcolor="#C0C0C0" align="center"><font face="Verdana" color="#000000" size="2"><b>Output Rate</b></font></td></tr>'; $sql = "SELECT id,name FROM units WHERE class={$row[0]} AND visible=1"; $r2 = mysql_query($sql) or die (mysql_error()); while ($row2 = mysql_fetch_row($r2)) { echo '<tr><td align="center">'.$row2[1].'</td><td align="center"><input text="text" size="5" style="'.$boxStyle.'" name="a'.$row2[0].'" value='.getRate($userid,$row2[0]).'>%</td></tr>'; } echo '<tr><td colspan="2" align="center"><input type="submit" value="Set Rates for '.$row[1].'"></td></tr>'; echo '</table></form>'; } echo '</center>'; }else if ($sc == "do") { $sql = "SELECT id FROM classes WHERE team={$teamid}"; $r = mysql_query($sql) or die (mysql_error()); $tot = 0; while ($row = mysql_fetch_row($r)) { $cur = 'a' . $row[0]; $$cur = round($$cur); $$cur += 0; $$cur = max(0,$$cur); $pass[$row[0]] = $$cur; $tot += $$cur; } if ($tot > getValue($userid, turns)) { echo '<center><B>You do not have enough turns to construct these buildings.</B><BR>[<a href="index.php?cmd=build">Back to '.gloss('barracks', $teamid).'</a>]'; }else { echo '<center><B>Buildings constructed</b><BR>[<a href="index.php?cmd=build">Back to '.gloss('barracks', $teamid).'</a>]<BR>'; spendTurns($userid, $tot, $teamid, $pass); $sql = "SELECT id FROM classes WHERE team={$teamid}"; $r = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_row($r)) { $cur = 'a' . $row[0]; makeBuildings($userid, $row[0], $$cur); } } }else if ($sc == "rate") { $sql = "SELECT id FROM units WHERE class={$bid}"; $r = mysql_query($sql) or die (mysql_error()); $tot = 0; while ($row = mysql_fetch_row($r)) { $cur = 'a' . $row[0]; $$cur = max(0,$$cur); $tot += $$cur; } if ($tot != 100) { echo '<center><B>Output rates do not add up to 100%.</B><BR>[<a href="index.php?cmd=build">Back to '.gloss('barracks', $teamid).'</a>]'; }else { echo '<center><B>Output rates have been set!</B><BR>[<a href="index.php?cmd=build">Back to '.gloss('barracks', $teamid).'</a>]'; $sql = "SELECT id FROM units WHERE class={$bid}"; $r = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_row($r)) { $cur = 'a' . $row[0]; setRate($userid, $row[0], $$cur); } } } ?> [code] Quote Link to comment https://forums.phpfreaks.com/topic/218015-database-problem/#findComment-1131748 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.