javascript - highcharts $_post['value'] does not print chart values ← (PHP, JavaScript, JQuery, HTML)

one text

I wanted to create a highchart using a dropdown and the selected value should be used in the where clause in a select statement. But if I click on the button then the chart is printed but with no values (e.g. dbsize, or timestamp...). If I change the $db variable to "postgres" or something like that, the chart will be printed normally.

Here is the html code:


<iframe name="hideframe" id="hideframe" style="display: none;"></iframe> 
<form action="printchart.php" method="post" target="hideframe" >

        <div class="dropdown" >
                <select class="form-control" name="thenumbers" >
                  <option value="postgres">postgres</option>
                  <option value="template1">template1</option>
                  <option value="testdb">testdb</option>
                </select>
        </div>

<button name="Button5" id="Button5">click</button>



<div id="container" style="height: 400px; min-width: 310px">
    <?php include("printchart.php"); ?>
</div>

And here is the printchart.php File including js for highchart:

<?php
require("00connection.php");
$db = $_POST['thenumbers'];
//$db = "postgres";


?>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">

$('#Button5').click(function () {
    

$(document).ready(function() {
        var options ={
            chart: {
                renderTo: 'container',
                type: 'line',
                zoomType: 'x',
        setSize: 400
            },
            title: {
                text: "DB-Size"  
            },
            xAxis: {
                categories: [
                    <?php
                $sql =  $conn->query("SELECT  dbname,dbsize, epoch_time FROM dbstats WHERE dbname = '$db' ORDER BY epoch_time;")->fetchAll();
                foreach ($sql as $row) {

                ?> '<?php //echo (date('Y-m-d h:i:sa',$row['epoch_time'])) 
                    $date = $row['epoch_time'] / 1000;
                    echo (date('Y-m-d H:i', $date)) ?>',
                <?php
                }
                ?>
                ],
                title: {
                    text: "Datetime"
                },
                type:'datetime',
                labels: {
            format: '{value:%Y-%m-%d %H:%M}',
                }
            },
            yAxis: {    
                title: {
                    text: 'DB-Size'
                }
            },
            rangeSelector: {
                enabled: true,
                inputEnabled: false,
                buttonPosition: {
                 allign: 'left'
                },
                labelStyle: {
                    display: 'none'
                },
                buttons: [{
                    type: 'month',
                    count: 1,
                    text: '1m'
                },
                          {
                    type: 'month',
                    count: 3,
                    text: '3m'
                }
                ]
            },
             tooltip: {
                //crosshairs: true,
                shared: true,
                valueSuffix: 'MB',
                xDateFormat: '%Y-%m-%d %H:%M'
             },
             series: [{         
                 name: 'DB-Size',
                 data: [
                <?php
                     
                $sql =  $conn->query("SELECT dbname, dbsize, epoch_time FROM dbstats WHERE dbname = '$db' ORDER BY epoch_time;")->fetchAll();
                foreach ($sql as $row) {

                ?>
                    <?php echo $row['dbsize'] ?>,
                <?php
                }
                ?>
            ]
        }]
        };
        var chart = new Highcharts.Chart(options);
    });
    
 });   
</script>


The sql statements are executed normally in both cases (if i get the value using $_POST from the form or if I create a variable and initialize it with postgres (like $db="postgres") but if I assing $db=$_POST['thenumber'] then the chart will not be printed although the select statements are executed.

I hope anybody can help me :)

Here is the image: highcharts_img

Best regards

Source