3

I am using http://www.nonumber.nl/extensions/sourcerer in order to place some custom php code in an article to display all my registered users in the front end of my Joomla 3.3 site. I am new to this so appreciate any help.

The code does work however it displays the users all in one long line with no breaks and is very difficult to read,

like this:

id|username|email|id|username|email|id|username|email|... etc

Can somebody explain how I take a new line after each user, for example:

id|username|email|<br>
id|username|email|<br>
id|username|email|<br>

I have tried adding \n and other variations in single and double quoted but it won't seem to make any difference.

My code is below:

$db = JFactory::getDBO();
$query = "SELECT * FROM #__users" ;
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
     echo $row->id.'|'.$row->username.'|'.$row->email;<br>
}

Thanks

3

Try this,

echo $row->id.'|'.$row->username.'|'.$row->email.'<br>';
3

Along with @Tim Wilkinson's answer, I would also use up to date coding standards for doing your database query like so:

$db = JFactory::getDbo();
$query = $db->getQuery(true)
      ->select($db->quoteName('*'))
      ->from($db->quoteName('#__users'));
$db->setQuery($query);
$rows = $db->loadObjectList();

foreach ($rows as $row) {
    echo '<p>' . $row->id .'|'.$row->username.'|'.$row->email . '</p>';
}

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.