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 Answer 1

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

3
  • it did the job! And what about displaying it as a HTML row?
    – saibbyweb
    Commented May 31, 2014 at 15:42
  • 1
    Please ask as new question as it's a completely new topic but try something of your own first
    – Lodder
    Commented May 31, 2014 at 15:42
  • joomla.stackexchange.com/questions/1079/…
    – saibbyweb
    Commented May 31, 2014 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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