I need to display data in an article in tabular form.
I am using sourcerer by NoNumber for adding the select code in the article:
<?php
defined('_JEXEC') OR die("Restricted access");
$user =&JFactory::getUser();
$db =&JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('*');
$query->from('#__bat_score');
$query->where('id = 1'); //put your condition here
$db->setQuery($query);
//echo $db->getQuery();exit;
if ($db->getErrorNum()) {
echo $db->getErrorMsg();
exit;
}
return $db->loadObjectList();
// from Joomla Resources
// the current code is not showing anything
The error i'm getting is like in this image:
The desired output is displaying the rows of the mysql table in a html table.
Please suggest some guidance on this as the best method to show the database data in the articles. Thanks in advance.
var_dump($variable)
in certain areas to find out of anything is undefined. You should also make sure you quote your values, column name and table name. Have a read through the Joomla documentation for Database queries