1

I am trying to update data field with PHP recourd using var point. Here is my PHP code:

  $query_Recordset1 = "SELECT * FROM table";
  $Recordset1 = mysql_query($query_Recordset1, $egrid) or die(mysql_error());
  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  $totalRows_Recordset1 = mysql_num_rows($Recordset1);
  $Peak = mysql_result($Recordset1 ,0,"Peak");
  print $Peak;

The PHP script does work, however when I attempt to insert it into my .js document nothing happens. Here is my javascript:

    series: [{
        name: 'Peak Average',
        data: [18000],  //interval update in Add some life
        tooltip: {
            valueSuffix: ' Peak'
        }
    }]

},
 // Add some life
 function(chart) {
  setInterval(
     function() {
        var point = chart.series[0].points[0], newVal;
        $.get("peak.php", function(newVal) {
                console.log(newVal, typeof newVal);
                point.update(parseFloat(newVal));
        });
     }    
  ,5000);
 });

I have even tried making adjustments as per string versus number:

  point.update(newVal);

PLEASE HELP.

BrianB
  • 133
  • 1
  • 12
  • What do you mean nothing happens? Is the gauge loading at all or is it just blankspace? – Mooseknuckles Jan 06 '15 at 00:51
  • Thanks for your response. Sorry, if I specify a static value in the data field and leave the "Add Some Life" functionless the gauge loads on the page showing the data value - works fine. When I attempt to "add life" only a blank page loads - no gauge. – BrianB Jan 06 '15 at 02:15
  • In the PHP try to return value as json (json_encode function) – Sebastian Bochan Jan 06 '15 at 10:28
  • I modified the code with the following with no success. echo json_encode ($Peak); – BrianB Jan 07 '15 at 03:01
  • I removed the json_encode from my php script and added if (!chart.renderer.forExport) along with the proper amount of ")" and "}". This fixed the issue. – BrianB Jan 07 '15 at 03:28
  • @BrianB you should consider answering your question with the solution you've found. – carla Jun 05 '15 at 04:15

0 Answers0