1
$db = JFactory::getDbo();
$user = JFactory::getUser();
$query = $db->getQuery(true);
$query->select('username');
$query->from($db->quoteName('#__selected_packages'));
$query->where($db->quoteName('username') . " = ". $db->quote($user->username));
$db->setQuery($query);

$result = $db->loadResult();

$row = $db->loadrow();
print_r($row);

The output looks something like this:

Array (
    [0] => any_username
)

It only displays one column, but according to Joomla Docs it should display the whole row somewhat like this:

Array (
    [0] => any_username
    [1] => val_of_col1
    [2] => val_of_col2
    [3] => val_of_col3
)

Where am i wrong with the code?

Moreover, is there any way to display the row data in a HTML table?

1

The reason being is because you are only selecting the username in your database query. So try changing this:

$query->select('username');

to this

$query->select('*');

Hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.