Jump to content
MakeWebGames

Help with some code:


furn355

Recommended Posts

So i'm still learning my way around queries and the such.

I created something that works for my new attack system. Only thing is its about 50 lines when it could probably be 4 :P

Any help optimizing would be greatly appreciated!!

Thanks in advance

so the code:

 

// I use this to get each of the equipped items data!

$attkweapon  = $db->query("SELECT i.* FROM items i   WHERE i.itmid  IN({$ir['equip_primary']})"); 
$wep = mysql_fetch_array($attkweapon);

$attkarmor  = $db->query("SELECT i.* FROM items i   WHERE i.itmid  IN({$ir['equip_armor']})"); 
$arm = mysql_fetch_array($attkarmor);

$attkoffhand  = $db->query("SELECT i.* FROM items i   WHERE i.itmid  IN({$ir['equip_offhand']})"); 
$off =  mysql_fetch_array($attkoffhand);

$attkhead =  $db->query("SELECT i.* FROM items i   WHERE i.itmid  IN({$ir['equip_head']})"); 
$head = mysql_fetch_array($attkhead);

$attkmedal  = $db->query("SELECT i.* FROM items i   WHERE i.itmid  IN({$ir['equip_medal']})"); 
$med = mysql_fetch_array($attkmedal);

$attkattachment  = $db->query("SELECT i.* FROM items i   WHERE i.itmid  IN({$ir['equip_attachment']})"); 
$att =  mysql_fetch_array($attkattachment);

$attklegs =  $db->query("SELECT i.* FROM items i   WHERE i.itmid  IN({$ir['equip_legs']})"); 
$leg = mysql_fetch_array($attklegs);

$attkfeet  = $db->query("SELECT i.* FROM items i   WHERE i.itmid  IN({$ir['equip_feet']})"); 
$feet = mysql_fetch_array($attkfeet);

 

AND i print it out like this for now

The item name: the strength, defense and speed boosts.

(all to be rearranged once the code is optimized!)

 

".$wep['itmname']."  ".$wep['strength_boost']."  ".$wep['defense_boost']." ".$wep['speed_boost']." 

".$arm['itmname']."   ".$arm['strength_boost']." ".$arm['defense_boost']."  ".$arm['speed_boost']."

".$off['itmname']."   ".$off['strength_boost']." ".$off['defense_boost']."  ".$off['speed_boost']." 

".$head['itmname']."   ".$head['strength_boost']." ".$head['defense_boost']."  ".$head['speed_boost']."

".$med['itmname']."   ".$med['strength_boost']." ".$med['defense_boost']."  ".$med['speed_boost']." 

".$att['itmname']."   ".$att['strength_boost']." ".$att['defense_boost']."  ".$att['speed_boost']."

".$leg['itmname']."   ".$leg['strength_boost']." ".$leg['defense_boost']."  ".$leg['speed_boost']." 

".$feet['itmname']."   ".$feet['strength_boost']." ".$feet['defense_boost']."  ".$feet['speed_boost']."

 

ALso if $wep['itmname'] was == 0 How would i get it to print out "fists"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...