############################################# ##### Get corresponding name to item ID ##### ############################################# function getitem() { $query = "SELECT `name` FROM `item` WHERE `id` = '".$row['item']."'"; $result = mysql_query($query); $num=mysql_num_rows($result); $row = mysql_fetch_array($result); return $row['name']; } using the function.....