Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • in reply to: MySQL – (Displaying Date-Time values on a Chart Axis) #22017

    I’m not sure what I’m doing wrong, but I have a feeling it’s my JSON code… Here is a jsfiddle using my JSON and here is the code behind my JSON

    <?php
    
    $username = "";
    $password = "";
    $dbname = "";
    
    // Create connection
    $conn = new mysqli('localhost',$username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    
    $sql = "SELECT date FROM db";
    $result = $conn->query($sql);
    
    if ($result->num_rows > 0) {
        // output data of each row
    	$obj = array();
        while($row = $result->fetch_assoc()) {
    		$element = array($row["ban_date"]);
           	array_push($obj,$element);
    	}
    	echo json_encode($obj);
    } else {
        echo "0 results";
    }
    $conn->close();
    ?>
    in reply to: MySQL – (Displaying Date-Time values on a Chart Axis) #22015

    Ah ok. So my JSON should still work much like yours or do I need to change to be an array of objects (if so how would I do that? I’m not that familiar with JSON files in case you can’t tell) Thanks so much for Helping Priyanka :)

    in reply to: MySQL – (Displaying Date-Time values on a Chart Axis) #21998

    Thanks that’s perfect, quick of topic question how did you code your JSON? Your’s looks much better then mine :) http://banlister.com/graph-test/service.php

    in reply to: MySQL – (Displaying Date-Time values on a Chart Axis) #21964

    Yea that’s awesome, quick question? I’m using a JSON file to get the dates, how can I incorporate that into that example?

Viewing 4 posts - 1 through 4 (of 4 total)