Data for Chart is retrieved from Remote Site Database
Notes:We will retrieve data from remote MySql Datenbases. Remote site has php-RGraph installed and is using php-RGraph's MySql interface.
{rgraph height="400" width="600" variantThreedOffsety="10" variantThreedOffsetx="15" data="url" url="http://www.oberquembach.de/index.php?option=com_content&tmpl=getJsonDatafromDB" type="Bar" tooltip="#label# <br>#val# Hits" title="Most read at oberquembach.de" xaxisLabelsAngle="20" marginBottom="105" truncate_label="20,..." variant="3d" tooltipsPositionStatic="0"}sample006{/rgraph}
Here you have this PHP-Script - "getJsonDatafromDB.php", which has been installed in directory "../templates/system" on remote site (www.oberquembach.de):
<?php defined('_JEXEC') or die('Restricted access'); $lib = JPATH_ROOT . "/php-apps/RGraph/lib/rgraph_chart.php"; require_once ($lib); use phpRGraph\rgraph_chart; $db_config_file = $_SERVER["DOCUMENT_ROOT"] . "/configuration.php"; $sql="Select title, hits From j25_content Order By hits Desc Limit 10"; $dbdata = rgraph_chart::getDataFromDB($db_config_file, $sql); $data = array("labels"=>$dbdata[0], "data"=>$dbdata[1]); echo json_encode($data); ?>
Important: If you want to test this sample via copy/paste, ensure that you paste with option "paste as plain text" otherwise imbedded html-codes may invalidate your input.
go back...