I make a module where I want to graph my results from my main table ticket
, but my DB is modeled so that it takes the foreign keys of the other tables in this case my table is called prioridad
. My problem is that I do not know how I can refer to my table and the names it contains appear.
this is the code segment where you have to reference the other table
['<?php echo $res['name'] ?>', <?php echo $res['priority_id'] ?> ],
Greetings
<?php
require_once("conexion.php");
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highcharts Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<style type="text/css">
${demo.css}
</style>
<script type="text/javascript">
$(function () {
$('#container').highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: 'Personas Deudoras'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
}
}
}
},
series: [{
type: 'pie',
name: 'Deudores',
data: [
<?php
$sql=mysql_query("select * from ticket");
while ($res=mysql_fetch_array($sql)){
?>
['<?php echo $res['name'] ?>', <?php echo $res['priority_id'] ?> ],
<?php
}
?>
]
}]
});
});
</script>
</head>
<body>
<script src="Highcharts-4.1.5/js/highcharts.js"></script>
<script src="Highcharts-4.1.5/js/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>
</body>
</html>