I have a problem with selecting multiple lines and extracting them as one line. The problem is that Joomla stores data from the user file in two columns named profile_key and profile_value. I would like to get all the rows from the column "profile_key" with the name "profile.li_vid", "profile.li_kre" corresponding to the column "profile_value", where the values are "1".
draft
user_id | profile_key | profile_value
475 | profile.li_vid | "1"
475 | profile.li_kre | "1"
475 | profile.address1 | "1"
476 | profile.li_vid | "1"
476 | profile.li_kre | "1"
476 | profile.address1 | "1"
the code
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query
->select ($db->quoteName(array('a.id','a.name', 'b.profile_value','b.profile_key')))
->from ($db->quoteName('#__users','a'))
->where ($db->quoteName('b.profile_key') . " = " . $db->quote('profile.li%'))
->join('INNER', $db->quoteName('#__user_profiles','b').'ON('.$db->quoteName('a.id').'='.$db->quoteName('b.user_id').')')
->order($db->quoteName('a.name').'ASC')
;
$db->setQuery($query);
$rows = $db->loadObjectList();
When I repeat them on the screen in a foreach loop, they appear on separate rows in my table, because the code cycles through each query result in a row by row. I was thinking of a solution where I combine several lines into one, but how? I hope you can help me.