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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.