0

I am trying to retrieve data for Flot charts but I don't know how the process goes. I have created a query, grouped the data but don't know how to display them.

Below is the code!

           <h3 class="box-title">Area Chart</h3>
           <div class="box-body">
              <div class="chart">
                <canvas id="areaChart" style="height:300px"></canvas>
              </div>
            </div>

<?php
$dataset1 = array();
$sqlbar = mysql_query("SELECT level_apply AS level, COUNT(id) AS 'count' FROM application GROUP BY level");
while($row = mysql_fetch_assoc($sqlbar))
    {
        $dataset1[] = array (intval($row['level']),intval($row['count']));
    }
?>  

    {{ HTML::script('/admin/assets/js/jquery-2.2.3.min.js') }}
<script>
  $(function () {
    var dataset1 = <?php echo json_encode($dataset1); ?>;
    $.plot($("#areaChart"), [dataset1]); });
</script>
MeliDev
  • 87
  • 11
  • Every time you use [the `mysql_`](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) database extension in new code **[this happens](https://media.giphy.com/media/kg9t6wEQKV7u8/giphy.gif)** it is deprecated and has been for years and is gone for ever in PHP7. If you are just learning PHP, spend your energies learning the `PDO` or `mysqli` database extensions and prepared statements. [Start here](http://php.net/manual/en/book.pdo.php) – RiggsFolly Jul 03 '17 at 11:52
  • this is with php 5 and is working with other type of charts but i need flot chart – MeliDev Jul 03 '17 at 11:54

1 Answers1

0

it will be better way if you use AJAX or append the error with the question please refer to this https://www.w3schools.com/jquery/jquery_ajax_get_post.asp