Jump to content

Having trouble setting up my cron to request specific values


Tagg

Recommended Posts

I have been getting a few crons up for a game I have been working on. On my latest one I tried something a little above my skill level and need some help now.

 

The way it is suppose to work is there is a database for the users called km_users, where one of the rows is a clan they can join. After they join/create one in the game it sets the name of the clan in that row.

 

Then there is a clan table, km_clan, in that same database (its called a table right?), where I have a row for 'troop power'..which is where I have my problem.

 

 

I am trying to have a cron update that row regularly by taking all the users from the km_users table with the specific clan name/id and add in all their troops. Btw, there is 2 rows on km_users called 'offarmy' and 'dffarmy'.

 

So basically if 3 users are in the table, and 2 of them are in Clan A - Then the row in km_clan with trooppower would add the 2 users 'offarmy' and 'dffarmy' together and keep the third user to his own clan stats if they are in one. Here is my code, it will update the trooppower row but it posts the same number under each cartel... :(

 

  <?php
     include "/home/vfelixxv/public_html/ext/connect.php";

       if (isset($_SESSION['player'])) 
  {
       $player=$_SESSION['player'];
       if(isset($_GET['clan']))
  {

   $userstats="SELECT * from km_users where playername='$player'";
   $userstats2=mysql_query($userstats) or die("Could not get user stats");
   $userstats3=mysql_fetch_array($userstats2);

   $getclanstats="SELECT * from km_users where clanname='$userstats3[clanname]'";
   $getclanstats2=mysql_query($getclanstats) or die("Could not query stats");
   while($getclanstats3=mysql_fetch_array($getclanstats2))
{
     $skill += $getclanstats3[offarmy];
     $atkskill += $getclanstats3[dffarmy];
}

   $gettrooppower="Update km_clans set trooppower=$skill+$atkskill where name=$clan[name]";
   $gettrooppower2=mysql_query($gettrooppower) or die("Could not run trooppower");
}
}
?>

Thanks, I was trying some variations and tutorials I was reading through..kind of got mushed in there.

 

Would you know of a good way to call certain values out of the database? I can apply what I need on a php page, but I guess it's useless without a Session selecting what you need..if that makes any sense heh.

 

I'l be on google searching, if its not possible to do this or an alternative way is possible please let me know..you guys rock :)

 

 

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.