creation of barcode with PHP, Mysql and highcharts

0

a query I'm creating some graphs with PHP, Mysql and highcharts where I make a query to my database XXX and I return the data in a shekel to be inserting the data and gratifying with the styles of highcharts.

but nothing appears to me

if I separate the php codes and the javascript template if they work for me, ie php and the query if it shows me the data of the same handles the graphics template shows me the graphics, but if the ones in the code no longer It shows me nothing.

I make my PHP code and put it in the javascript with quotes '' and even then it does not show me anything

This is the code I'm using.

<?php
$opcion = 19;// $_POST["opcion"];
require 'conexion.php';
include 'header.php';
    //consulta para la tabla encuesta para capturar el titulo de la encuesta seleccionada
    $consulta = "SELECT titulo FROM encuestas WHERE id = $opcion";
    $consulta = mysqli_query($conexion, $consulta);
    while ($row = mysqli_fetch_array($consulta)){
    //aqui esta almacenado el titulo de mi encuesta. 
    $titulo = $row['titulo'];
       
    }
?>

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>Highcharts Example</title>

		<style type="text/css">

		</style>
	</head>
	<body>
            <script src="../graficas/code/highcharts.js" type="text/javascript"></script>
<script src="../graficas/code/modules/exporting.js" type="text/javascript"></script>
<div id="container" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>

		<script type="text/javascript">

Highcharts.chart('container', {
    chart: {
        plotBackgroundColor: null,
        plotBorderWidth: null,
        plotShadow: false,
        type: 'pie'
    },

    title: {
    //este es el titulo de la grafica
        text: '<?php $titulo?>'
        
    },
    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'
                }
            }
        }
    },
      <?php 
          //consulta para la tabla respuesta para capturar los votos y el texto
    $sql = "SELECT a.texto as titulo, SUM(CASE WHEN b.valor = 1 THEN 1 ELSE 0 END) AS 'si', SUM(CASE WHEN b.valor = 0 THEN 1 ELSE 0 END) AS 'NO' FROM respuestas a INNER JOIN opciones b ON a.id = b.id_pregunta WHERE a.idenc = $opcion GROUP BY a.id,a.texto";
    $sql = mysqli_query($conexion,$sql);
    //ahora recorremos los datos texto y votos que están vinculadas a la encuesta seleccionada
    while ($row = mysqli_fetch_array($sql)){
    $texto = $row["titulo"];
    $VSI = $row["si"];  
    $VNO = $row["NO"];
          
      ?>      
    series: [{
    //nombre de el concepto 
        name: '<?php $texto?>',
        colorByPoint: true,
        data: [{
        //cantidades
            name: 'SI',
            //la cantidad de la grafica con valor a si
            y: '<?php $VSI?>'
            name: 'NO',
            //la cantidad de la grafica con valor a no
            y: '<?php $VNO?>'
        },
        <?PHP } ?>
      ]
    }]
});
		</script>
	</body>
</html>
    
asked by antonio sanchez 23.02.2018 в 21:29
source

0 answers