How else can I get the name without putting the query in the foreach loop?
PHP:
$material_decode=json_decode($materials['materials']);
foreach($material_decode as $material_id=>$material_value)
{
$forge_materials=mysql_fetch_assoc(mysql_query('SELECT `name` FROM `forging_materials` WHERE `id`='.$material_id.' LIMIT 1'));
echo '<tr>'.
'<td>'.
$forge_materials['name'].
'</td>'.
'<td>'.
number_format($material_value).
'</td>'.
'</tr>';
}
$material_decode (forge_material_id => material_value):
stdClass Object
(
[2] => 25
[4] => 32
[5] => 23
)