So I'm trying to write a script where every few hours it gives certain adoptables a click. I have the loop working for giving the click, but I also want it to update the users table for the new "steps" as they're called. I can't get the second part to work... Any suggestions?
Thanks in advance!
Code:
$query = "SELECT * FROM ".$prefix."owned_adoptables WHERE tradestatus='PokeWalker'";
$result2 = mysql_query($query);
$num2 = mysql_num_rows($result2);
$article_title = "Ahuh.";
$article_content = "";
//Loop out code
$i=0;
while ($i < $num2) {
$aid=@mysql_result($result2,$i,"aid");
$type=@mysql_result($result2,$i,"type");
$name=@mysql_result($result2,$i,"name");
$totalclicks1=@mysql_result($result2,$i,"totalclicks");
$totalclicks = number_format($totalclicks1);
$currentlevel=@mysql_result($result2,$i,"currentlevel");
$usealternates=@mysql_result($result2,$i,"usealternates");
$tradestatus=@mysql_result($result2,$i,"tradestatus");
$isfrozen=@mysql_result($result2,$i,"isfrozen");
$owner=@mysql_result($result2,$i,"owner");
$gender=@mysql_result($result2,$i,"gender");
$original=@mysql_result($result2,$i,"original");
$obtained=@mysql_result($result2,$i,"obtained");
$happiness=@mysql_result($result2,$i,"happiness");
$ownerusername = $owner;
$query = "SELECT * FROM ".$prefix."users WHERE username='".$ownerusername."'";
$result3 = mysql_query($query);
$num3 = mysql_num_rows($result3);
$pokewalkersteps=@mysql_result($result3,$i,"pokewalkersteps");
$newpokewalkersteps = $pokewalkersteps + 1;
$query = "UPDATE ".$prefix."users SET pokewalkersteps='".$newpokewalkersteps."' WHERE username='".$ownerusername."'";
mysql_query($query);
$article_content = $article_content.$name." - ".$aid."<br>";
$newclicks = $totalclicks1 + 1;
//$query = "UPDATE ".$prefix."owned_adoptables SET totalclicks='".$newclicks."' WHERE aid='".$aid."'";
//mysql_query($query);
$article_content = $article_content.$ownerusername." - ".$newpokewalkersteps."<br>";
$i++;
}