well I've been foling around with damn chunk of code for the past few days...and I'm stumped. Basically what I'm trying to achieve is to display actions (to affect rpg stats for my forum) if the person who posted, equals the one in the database for the specific thread. Sounds simple right? Well there can be 2 to 6 people battling in the same thread, yet I only want the stats to show for the battling people, and not for the people who post their comments on how the battle is going. What I thought I could do is just the following:
1) Select all the fields from the rpg table where the logged threadid is equal to the current threadid
2) If #1 is true...continue to count rows returned (for the ammount of users)
3) Do a loop for each user to get their stats
Yet #3 is the problem. Here is my code:
$query = "SELECT rpgusers,rpgthreadid FROM bb".$n."_rpgregisterlog WHERE rpgthreadid=".$threadid;
$r = mysql_query($query) or die(mysql_error());
//!!!!!!!!!!!!!!!!!!!!
$datac = mysql_fetch_array($r);
if($boardid==9 && $datac==$posts[userid]){
//!!!!!!!!!!!!!!!!!!!!
$rpgstatquery = $db_zugriff->query("SELECT * FROM bb".$n."_rpgregisterlog WHERE rpgusers=".$posts[userid]) or exit("Can't Connect!");
$data = $db_zugriff->fetch_array($rpgstatquery);
$levela = $data['rpglevel'];
$ep = floor (100 * ($levela - floor ($level)));
$showlevel = floor ($levela + 1);
$rpgphyatt = $data['rpgphyatt'];
$rpgphydef = $data['rpgphydef'];
$rpgmagatt = $data['rpgmagatt'];
$rpgmagdef = $data['rpgmagdef'];
$rpgspeed = $data['rpgspeed'];
$rpgevade = $data['rpgevade'];
eval ("\$rpgactions = \"".gettemplate("rpgactions")."\";");
eval ("\$rpgstaticstats = \"".gettemplate("rpgstaticstats")."\";");
} elseif($boardid!=9){
$rpgstatquery = $db_zugriff->query("SELECT * FROM bb".$n."_user_table WHERE userid=".$posts[userid]) or exit("Can't Connect!");
$datab = $db_zugriff->fetch_array($rpgstatquery);
$levelb = pow (log10 ($posts[userposts]), 3);
$ep = floor (100 * ($levelb - floor ($level)));
$showlevel = floor ($levelb + 1);
$rpgphyatt = $datab['rpgphyatt'];
$rpgphydef = $datab['rpgphydef'];
$rpgmagatt = $datab['rpgmagatt'];
$rpgmagdef = $datab['rpgmagdef'];
$rpgspeed = $datab['rpgspeed'];
$rpgevade = $datab['rpgevade'];
eval ("\$rpgstaticstats = \"".gettemplate("rpgstaticstats")."\";");
}
the part I outlined is the part I'm having trouble with. $datac returns the correct values in the database, yet it returns them as so:
1
2
It puts a line break inbetween them. How would I get it to split the $datac into two variables? I've tried $datac[0], $datac[1] AND $datac[rpgusers][0], $datac[rpgusers][0] yet they didn't work. And if I do solve that problem, how would I do the if statement below the $datac variable if there can be upto 6 players? Would I do a for loop? Yet is that possible in the if statements conditions area ( if(I'm talking about this area in here) )? Please help me!