| Pages: [1] :: one page |
| Author |
Thread Statistics | Show CCP posts - 0 post(s) |

Ghorth
|
Posted - 2010.12.01 08:53:00 -
[1]
Hi,
I recently uploaded the Mysql dump of the Tyrannis 104 version (thanks to Jercy Fravowitz) and tried to connect the TypeID of my skills (in character sheet) to the their names.
But for some reason I keep getting #System as result.
Here is my script
Quote: foreach($api->CharacterSheet(array("characterID" => $character->characterID))->skills as $skill) { $skillID += $skill->typeID; $query = $this->db->query('SELECT invTypes.typeName AS skillName FROM invTypes WHERE invTypes.typeID = "$skillID"'); foreach ($query->result()as $row) { $skillname = $row->skillName; } echo "SkillID = " .$skill->typeID . " | SkillName = " . $skillname . " = " . $skill->skillpoints . "<br />"; }
Any ideas why? btw this script isn't final... I'm testing out the API for the first time :) fyi I use codeigniter... But in my opinion there shouldn't be any difference in knowledge :S
|

Project 69
|
Posted - 2010.12.01 09:04:00 -
[2]
Quote: $skillID += $skill->typeID;
unless I miss something, but this looks like you accumulate the $skillID values loop after loop. so basically only the first skill should show, all the rest wouldn't exist (unless to a very lucky number)
try
Quote: $skillID=$skill->typeID."";
instead
|

Ghorth
|
Posted - 2010.12.01 09:09:00 -
[3]
Woops forgot to mention
Everything works (so I get the typeID and amount of skillpoints) except the skillname.
|

Project 69
|
Posted - 2010.12.01 09:09:00 -
[4]
you may try to do less SQL request too tho, your database will thank you
|

Ghorth
|
Posted - 2010.12.01 09:25:00 -
[5]
what do you mean?
I'm still a rookie in php/MySql :)
|

Project 69
|
Posted - 2010.12.01 09:32:00 -
[6]
Edited by: Project 69 on 01/12/2010 09:32:36 i'm no the crack either, but here would be my version of this script
$myskills=array(); $mypoints=array(); foreach($api->CharacterSheet(array("characterID" => $character->characterID))->skills as $skill) { $nowid=$skill->typeID.""; $myskills[]=$nowid; $mypoints[$nowid]=$skill->skillpoints.""; } $sql="SELECT t.typeName,t.typeID,g.groupID,g.groupName FROM invTypes t,invGroups g WHERE t.groupID=t.groupID AND t.typeID IN (".join(",",$myskills).") ORDER BY groupName,typeName ASC"; $query = $this->db->query($sql); foreach ($query->result()as $row) { $skillid=$row[typeID]; echo "SkillID = $skillID | SkillName = " . $row[typeName]. " = " . $mypoints[$skillid]. "<br />"; }
unless I wrote an error, but this would only do one sql request, fetching the Skill and it's group(if you wanna do that)
|

Ghorth
|
Posted - 2010.12.01 09:36:00 -
[7]
Oh okay, yes wasn't paying attention to the query placement... Shouldn't have put it inside the loop :)
Well I'll look into that.
Thanks
|
| |
|
| Pages: [1] :: one page |
| First page | Previous page | Next page | Last page |