Jump to content

how to create a loop


chriscloyd

Recommended Posts

hi i want to reloop this code

[code]
$email = $_SESSION['firefight'];
$userinfo = mysql_query("SELECT * FROM users WHERE email = '$email'");
$info = mysql_fetch_assoc($userinfo);
$set_population = $info['population'];
$set_cash = $info['cash'];
$set_turns = $info['turns'];
$set_food = $info['food'];
$set_metal = $info['metal'];
$set_lt = $info['lt'];
$set_turrets = $info['turrets'];
$set_nukes = $info['nukes'];$timesc = rand(100,5000);
$new_moneys = .15 * $timesc;
$new_money = floor($new_moneys);
$cash = $set_cash + $new_money;
$timesp = rand(0,100);
$population = $set_population + $timesp;
$fooduseds = .023 * $set_population;
$foodused = floor($fooduseds);
$food_produced = rand($foodused,$set_food);
$food = $set_food - $foodused + $food_produced;
$turns = $set_turns - $i;
$units = .80 * $population;
$unit = floor($unites);
$nukes = .05 * $units;
$nuke = floor($nukes);
$lts = .45 * $units;
$lt = floor($lts);
$turretss = .30 * $units;
$turrets = floor($turretss);
$metals = rand(100,5000);
$metal = $set_metal + $metals;
echo '<table width="430" border="0" cellspacing="3" cellpadding="0">
  <tr>
    <td width="241">Population Produced: <span class="green">+'.$population.'</span></td>
    <td width="230"><div align="center">From the increase of your population you recieved </div></td>
  </tr>
  <tr>
    <td>Cash Produced: <span class="green">+'.$cash.'</span></td>
    <td>Light Armor Units: <span class="green">+'.$lt.'</span></td>
  </tr>
  <tr>
    <td>Metal Produced: <span class="green">+'.$metal.'</span></td>
    <td>Turrets: <span class="green">+'.$turrets.'</span></td>
  </tr>
  <tr>
    <td>Turns: -1 </td>
    <td>Nukes: <span class="green">+'.$nukes.'</span></td>
  </tr>
  <tr>
    <td>Food Used: <span class="red">-'.$foodused.'</span></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>Food Produced: <span class="green">+'.$food_produced.'</span></td>
    <td>&nbsp;</td>
  </tr>
</table>';
mysql_query("UPDATE users SET food = '$food', cash = $cash, population = '$population',turns = '$turns', metal = '$metal', lt = '$lt', nukes = '$nukes', turrets = '$turrets' WHERE email = '$email'");
[/code]

when someone enters a number on this form
[code]
<form name="form1" method="post" action="?page=cash_action">
<label>How many turns do you wanna spend on cash?
<input name="turns" type="text" id="turns">
</label>
<br>
<label>
<input type="submit" name="Submit" value="Show me the money">
</label>
</form>[/code]
Link to comment
https://forums.phpfreaks.com/topic/29622-how-to-create-a-loop/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.