xxhopeful Posted September 22, 2006 Share Posted September 22, 2006 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! Quote Link to comment Share on other sites More sharing options...
dragonusthei Posted September 22, 2006 Share Posted September 22, 2006 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 Quote Link to comment Share on other sites More sharing options...
xxhopeful Posted September 22, 2006 Author Share Posted September 22, 2006 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] Quote Link to comment Share on other sites More sharing options...
Barand Posted September 22, 2006 Share Posted September 22, 2006 [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] Quote Link to comment Share on other sites More sharing options...
xxhopeful Posted September 22, 2006 Author Share Posted September 22, 2006 i got it, thanks for the help Barand! Quote Link to comment 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.