Ok this is building on what I was previously working on in my last post:
<?php
$db = JFactory::getDBO();
$db->setQuery("SELECT `profile_value` FROM #__user_profiles WHERE `user_id`='customer_id' AND `profile_key`='profile.address1'");
$result = $db->loadResult();
echo $db->loadResult();
?>
So in this situation, I have to reference customer_id from a different table than the rest of this. How would I go about pointing just that one field that is located in this other table (rsticketspro_tickets)
Or am I going about this in the completely wrong way? I'm trying to place this code to pull an address from a users profile on a "View Ticket" screen. So the customer_id is what is referenced on that page I believe, so maybe its already a variable?
NEW CODE
<?php
$db = JFactory::getDBO();
$db->setQuery("SELECT `profile_value` FROM #__user_profiles WHERE `user_id`='rsticketspro_tickets.customer_id' AND `profile_key`='profile.address1'");
$result = $db->loadResult();
echo $db->loadResult();
?>
NEW NEW CODE
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->qn('a.profile_value'))
->from($db->qn('#__user_profiles'), 'a')
->join('INNER', $db->quoteName('#__rsticketspro_tickets', 'b') . ' ON (' . $db->qn('a.user_id') . " = " . $db->q(b.customer_id) . ')')
->where($db->qn('a.profile_key') . " = " . $db->q('b.address1'));
$db->setQuery($query);
$result = $db->loadResult();
This might help, but I cant seem to see whats wrong in everything at the moment still.
TABLE: #__user_profiles
COLUMNS: user_id, profile_key, profile_value
PROFILE_KEY VALUE: profile.address1
TABLE: #__rsticketspro_tickets
COLUMNS: customer_id
".$item->id."
- but I cant seem to find the equivalent for customer_id.