I am trying to do a simple calculation on two Joomla custom fields in a module. I get the article ID as a variable and want to put this in the WHERE clause to get the right custom field value. Have tried many thing, but can't manage. The field_id is 4 of the field I need and when I fill in the article ID as a number, it is working, but I can't get the variable to work (which I need so the module uses the article ID). Hope somebody can help me out?
$article_id = JFactory::getApplication()->input->get('id'); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('value', 'item_id', 'field_id') ->from ($db->quoteName('#__fields_values')) ->where($db->quoteName('#__fields_values.field_id=4')) ->where($db->quoteName('#__fields_values.item_id')=$article_id); $db->setQuery($query); $result = $db->loadResult(); return $result; Thanks!