0

Running one single instance of the justgage which retrieves the "count" value of my select statement (Which I've retrieved from the net) This is working fine. It shows the amount of issues where the prio(ority) equals 2.

Here's my challenge. I wish to have 5 gauges, for each gauge I want to its value to be retrieved and showed from the database. However I can't figure out the $query command.

This is my php part:

  <?php

  // connect to the database
    include('connect-db.php');
   // Make a MySQL Query and assign variable
    $query = "SELECT COUNT(prio) as prio_a FROM ticket WHERE prio=2";       
   //assign result to a variable
    $result = mysql_query($query) or die(mysql_error());
   //fetch result as an associative array
    $data = mysql_fetch_assoc($result) or die(mysql_error());
?> 

This is my gauge:

<div id="r1"></div>

<script>
        var r1 = new JustGage({
          id: "r1",
          value: <?php echo $data['prio_a']; ?>,
          min: 0,
          max: 100,
          title: "Prio Geen",
          label: "PRIORITEIT"
        });

</script>

My idea was: A second gauge would look like this?

<div id="r1"></div>

<script>
        var r2 = new JustGage({
          id: "r2",
          value: <?php echo $data['prio_b']; ?>,
          min: 0,
          max: 100,
          title: "Prio Geen",
          label: "PRIORITEIT"
        });

</script>

Hopefully I can then continue with even more gauges (Five for 'priorities', Nine for 'status", Eight for 'type of issues' and two for 'open/closed tickets')

Any help, ideas would be appreciated.

4

2 回答 2

0

我已经解决了一个变通办法。我已经在数据库中创建了一个存储过程,我从中检索结果作为 Json 数组。感谢您提供所有信息。

PS:@RiggsFolly:对猫过敏;)所以或多或少一只猫......

新年快乐!

于 2017-01-05T10:43:15.260 回答
0

你可以试试

SELECT prio, COUNT(prio) as tot FROM ticket 
GROUP BY prio
WHERE prio in (1,2,3,4,5)
ORDER BY prio

如果您只有 5 个 prio 值,您可以忘记 WHERE 子句

这将返回 5 个结果行,您可以在处理结果集的 while 循环中构建 javascript

于 2017-01-02T15:59:14.660 回答