So.. some of you may know that i'm making a Browser Based Game about Business..
Basicly its a game where you can open your own business and it's just like real world, with taxes and stuff.
Well.. i was coding a simple system that allow players to check their previous payments.
Here's the code:
Code: Select all
if(isset($_POST['playername']))
{
echo "<form method='POST' action='gerir.php'> <input type='submit' value='Go Back' name='submit'> </form>";
$player = $_POST['playername'];
$query = mysql_query("SELECT * FROM `pagamentos` WHERE `username`='$player' ORDER BY `data` DESC"); // this will select all payments from the payments table of couse it will only select the player ones.
$result = mysql_fetch_array($query);
$num = mysql_numrows($query);
$i=0;
// So here it's the problem, i got only 1 field (1 payment) so it should go to the while loop one time and then stop... but nop.. it never stops presenting the same payment.
while ($i < $num ) {
$data = mysql_result($query,$i,"data");
$pagamento = mysql_result($query,$i,"pagamento");
$irc = mysql_result($query,$i,"irc");
$seg_social_gerente = mysql_result($query,$i,"seg_social_gerente");
$seg_social_empregados = mysql_result($query,$i,"seg_social_empregados");
$agua = mysql_result($query,$i,"agua");
$luz = mysql_result($query,$i,"luz");
$gas = mysql_result($query,$i,"gas");
$lucro = mysql_result($query,$i,"lucro");
$ganhos = mysql_result($query,$i,"ganhos");
$gastos = mysql_result($query,$i,"gastos");
echo "<br><u>Pagamento de $data</u>";
echo "<br>Pagamento efectuado: $pagamento";
echo "<br>Irc: $irc";
echo "<br>Segurança Social do Gerente: $seg_social_gerente";
echo "<br>Segurança Social de Empregados: $seg_social_empregados";
echo "<br>Água: $agua";
echo "<br>Luz: $agua";
echo "<br>Gás: $gas";
echo "<br>Lucro: $lucro";
echo "<br>Prejuizo: $gastos";
}
}
else
{
echo '<meta http-equiv="refresh" content="0; URL=gerir.php">';
}Hope you guys can help me.
Credits:
If you help, you got credited.