Jump to content

Archived

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

xxhopeful

im stumped *solved*

Recommended Posts

i've been working on an equine sim game, and i'm trying to create a script that will pull the horses from the database that are on a certain team. then it will take the statistic (also from the database) and add all their statistic together to make one total score. i am unsure about how to create the script so it adds each individual horses score together, as right now i can only get it to add one of their scores. let me know if you have any ideas! thanks!

Share this post


Link to post
Share on other sites
urm..

i would just get the number of horses from the database then do a for loop with the number of horses adding each horses score together

Share this post


Link to post
Share on other sites
this is the current script i have, but all it does is add ONE of the horses scores together..not all of the horses scores:
[code]
$querryss=mysql_query("SELECT talent,conformation,strength,agility,conformation,endurance,intelligence,speed,trainedin,gender,name,hid from horses where drivingteam='$drivingteamid'")or die(mysql_error());
      $numss=mysql_num_rows($querryss);

if($numss == "0"){
print "No horses on this team.";
exit;
}

      for($i=0; $i<$numss; $i++){

                $hrowedd=mysql_fetch_array($querryss);

$teamscore=$hrowedd[talent]+$hrowedd[conformation]+$hrowedd[strength]+$hrowedd[agility]+$hrowedd[endurance]+$hrowedd[intelligence]+$hrowedd[speed]+$hrowedd[talent]+$hrowedd[conformation]+$hrowedd[strength]+$hrowedd[agility]+$hrowedd[endurance]+$hrowedd[intelligence]+$hrowedd[speed];
}[/code]

Share this post


Link to post
Share on other sites
[code]
<?php
$teamscore = 0;
for($i=0; $i<$numss; $i++){

      $hrowedd=mysql_fetch_array($querryss);

      $teamscore += $hrowedd[talent] + hrowedd[conformation] + $hrowedd[strength] + $hrowedd[agility] +
          $hrowedd[endurance] + $hrowedd[intelligence] + $hrowedd[speed] ;
}
echo $teamscore;
?>[/code]

Share this post


Link to post
Share on other sites

×

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.