McBryver Posted April 22, 2010 Share Posted April 22, 2010 Here is the units page: <? include_once("../config.php"); $s = new Game(); $personnel = $s->getPersonnel($_SESSION['userid']); ?> <table width="100%" border="0"> <tr> <td colspan="2" align="center">Personnel</td> </tr> <tr> <td width="37%" align="left"><?= $personnel->attackName; ?></td> <td width="63%" align="right" valign="middle"><?= number_format($personnel->attackCount); ?></td> </tr> <tr> <td align="left"><?= $personnel->superAttackName; ?></td> <td align="right" valign="middle"><?= number_format($personnel->superAttackCount); ?></td> </tr> <tr> <td align="left"><?= $personnel->attackMercName ?></td> <td align="right" valign="middle"><?= number_format($personnel->attackMercCount); ?></td> </tr> <tr> <td align="left"><?= $personnel->defenseName; ?> </td> <td align="right" valign="middle"><?= number_format($personnel->defenseCount); ?></td> </tr> <tr> <td align="left"><?= $personnel->superDefenseName; ?> </td> <td align="right" valign="middle"><?= number_format($personnel->superDefenseCount); ?></td> </tr> <tr> <td align="left"><?= $personnel->defenseMercName; ?></td> <td align="right" valign="middle"><?= number_format($personnel->defenseMercCount); ?></td> </tr> <tr> <td align="left">Untrained</td> <td align="right" valign="middle"><?= number_format($personnel->uuCount); ?></td> </tr> <tr> <td align="left">Miners (Lifers) </td> <td align="right" valign="middle"><? $x = $personnel->minerCount+$personnel->liferCount; print number_format($x); ?>( <?= number_format($personnel->liferCount); ?> )</td> </tr> <tr> <td align="left"><?= $personnel->covertName; ?></td> <td align="right" valign="middle"><?= number_format($personnel->covertCount); ?></td> </tr> <tr> <td align="left"><?= $personnel->superCovertName; ?></td> <td align="right" valign="middle"><?= number_format($personnel->superCovertCount); ?></td> </tr> <tr> <td align="left"><?= $personnel->anticovertName; ?></td> <td align="right" valign="middle"><?= number_format($personnel->anticovertCount); ?></td> </tr> <tr> <td align="left"><?= $personnel->superAnticovertName; ?></td> <td align="right" valign="middle"><?= number_format($personnel->superAnticovertCount); ?></td> </tr> <tr> <td>Total</td> <td align="right" valign="middle"><?= number_format($personnel->ttlarmysize); ?></td> </tr> </table> Here is the class File: class Game extends User { /*Vars*/ var $gameTime; //Time In Game var $isRank; //Players Rank out of all active users var $actionTurns; //Number of Action Turns Use has to use var $inHand; //Ammount of Money On Handl var $inBank; //Ammount of Money Bankedlol var $nextTurn; //Ammount of Time Till Next Turn var $numMessages; //Number of Messages In Users Inbox var $uid; //UserID var $rid; //Race Identifier var $fields; //field List function getPersonnel($uid) { $query = "SELECT units.attack AS attackCount, units.superAttack AS superAttackCount, units.attackMercs AS attackMercCount, units.defense AS defenseCount, units.superDefense AS superDefenseCount, units.defenseMercs AS defenseMercCount, units.untrained AS uuCount, units.miners AS minerCount, units.lifers AS liferCount, units.covert AS covertCount, units.superCovert AS superCovertCount, units.anticovert AS anticovertCount, units.superAnticovert AS superAnticovertCount, unitnames.attack AS attackName, unitnames.superAttack AS superAttackName, unitnames.attackMercs AS attackMercName, unitnames.defense AS defenseName, unitnames.superDefense AS superDefenseName, unitnames.defenseMercs AS defenseMercName, unitnames.covert AS covertName, unitnames.superCovert AS superCovertName, unitnames.anticovert AS anticovertName, unitnames.superAnticovert AS superAnticovertName, unitcost.attack AS attackCost, unitcost.superAttack AS superAttackCost, unitcost.defense AS defenseCost, unitcost.superDefense AS superDefenseCost, unitcost.covert AS covertCost, unitcost.superCovert AS superCovertCost, unitcost.anticovert AS anticovertCost, unitcost.superAnticovert AS superAnticovertCost, SUM( units.attack+ units.superAttack+ units.attackMercs+ units.defense+ units.superDefense+ units.defenseMercs+ units.untrained+ units.miners+ units.lifers+ units.covert+ units.superCovert+ units.anticovert+ units.superAnticovert ) AS ttlarmysize FROM `units`, `unitnames`,`userdata`,`unitcost` WHERE userdata.uid = ".$uid." AND unitnames.rid = userdata.rid AND units.uid = userdata.uid AND unitcost.rid = userdata.rid GROUP BY userdata.uid LIMIT 1"; $q = $this->query($query); $person = mysql_fetch_object($q); return $person; } } For some reason its not displaying any information from the database. Its boggling my mind. Bryver Quote Link to comment https://forums.phpfreaks.com/topic/199358-unit-display/ Share on other sites More sharing options...
trq Posted April 22, 2010 Share Posted April 22, 2010 Your really going to need to attempt to narrow the problem down somewhat before simply posting 'it doesn't work'. What should the query method of the Game class return? Sounds like it belongs in a database object not a Game object, but anyway, you should at least attempt to test its return value before simply passing it off to mysql_fetch_object. Quote Link to comment https://forums.phpfreaks.com/topic/199358-unit-display/#findComment-1046281 Share on other sites More sharing options...
ignace Posted April 22, 2010 Share Posted April 22, 2010 if ($q === false) { trigger_error("query failed: " . mysql_error()); } Quote Link to comment https://forums.phpfreaks.com/topic/199358-unit-display/#findComment-1046291 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.