PDA

View Full Version : Can this be reduced


Jalrock
12-03-2002, 09:36 PM
Can this be reduced into a single query? if so how do I call each attribute?



$memhealth=$DB_site->query_first("SELECT battle_health FROM user WHERE userid='$bbuserinfo[userid]'");
$battle_health=$memhealth[battle_health];

$memintel=$DB_site->query_first("SELECT battle_intel FROM user WHERE userid='$bbuserinfo[userid]'");
$battle_intel=$memintel[battle_intel];

$memmagic=$DB_site->query_first("SELECT battle_magic FROM user WHERE userid='$bbuserinfo[userid]'");
$battle_magic=$memmagic[battle_magic];

$memskill=$DB_site->query_first("SELECT battle_skill FROM user WHERE userid='$bbuserinfo[userid]'");
$battle_skill=$memskill[battle_skill];

$memarmor=$DB_site->query_first("SELECT battle_armor FROM user WHERE userid='$bbuserinfo[userid]'");
$battle_armor=$memarmor[battle_armor];

$DB_site->free_result($memhealth);
$DB_site->free_result($memintel);
$DB_site->free_result($memmagic);
$DB_site->free_result($memskill);
$DB_site->free_result($memarmor);

eval("\$battle_mem_stats = \"".gettemplate('battle_mem_stats')."\";");


I think this is the first part????
$membattlestats=$DB_site->query_first("SELECT battle_armor, battle_intel, battle_magic, battle_skill, battle_armor FROM user WHERE userid='$bbuserinfo[userid]'");
but I dont know how the rest is done?

Any help greatly appreciated.

JulianD
12-03-2002, 10:47 PM
The rest could be something like this:


$battle_health = $membattlestats['battle_health'];
$battle_intel = $membattlestats['battle_intel'];
$battle_magic = $membattlestats['battle_magic'];
$battle_skill = $membattlestats['battle_skill'];
$battle_armor = $membattlestats['battle_armor'];

Jalrock
12-03-2002, 11:52 PM
Thanks, I will try it but I thought there had to be a while statment there somewhere.

JulianD
12-04-2002, 12:10 AM
Uhmmm I don't think so.. Try it yourself and post here if you have any problem.

Jalrock
12-04-2002, 12:33 AM
All is good it worked great. Thanks