Jump to content

engy123

New Members
  • Posts

    4
  • Joined

  • Last visited

engy123's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I am trying to connect to a database using mysqli from a web developing software package called Sellerdeck. This software is purely windows based, it has PHP configured to a certain extent it seems. I ran the phpinfo(); command and can't find anything to do with MYSQL in the settings of the version. So i tried to download the php_mysql.dll and libmysql.dll files, I have referenced them in the php.ini file by using extension_dir="./" extension=php_mysql.dll extension=libmysql.dll (Also best to mention that " extension_dir="./" " was the only line of text in the php.ini file by default) This didn't seem to make a difference at all, still get the same error. Is there anything I can try to do? I really can't understand it as php 5 comes with mysql built in, but it seems that Sellerdeck have stripped that usability from the php version! Any advice appreciated
  2. Hi mate, I tried putting this into my code - $intermediate[$key][] = array('x' => count($intermediate[$key][]), 'y' => $y); and i got the following error - Fatal error: Cannot use [] for reading in C:\wamp\www\multibar.html.php on line 23 So i tried - $intermediate[$key][] = array('x' => count($intermediate[$key]), 'y' => $y); But got lots of un-identified index errors, although the X was counting correctly in the data output. Any ideas? Thanks
  3. I'm using the following function/php code to create some JSON for some NVD3 charts I am using. The problem I have is that for each KEY, the $i variable will count even and odd numbers. Here is the data below as you can see in the first line, every x:counts as 0, 2, 4 , 6. and for KEY:IDNB it counts 1,3,5,7. I need them all to count equally so that they are against the same line on my graph. How can I make them count 1,2,3,4 for both "keys" [{"key":"IDNA","values":[{"x":0,"y":387.73},{"x":2,"y":388.57},{"x":4,"y":388.04},{"x":6,"y":387.94},{"x":8,"y":388.24},{"x":10,"y":388.44},{"x":12,"y":387.99},{"x":14,"y":388.53},{"x":16,"y":388.79},{"x":18,"y":388.6},{"x":20,"y":388.55},{"x":22,"y":388.48},{"x":24,"y":388.72},{"x":26,"y":389.02},{"x":28,"y":388.59},{"x":30,"y":388.07},{"x":32,"y":388.14},{"x":34,"y":388.58},{"x":36,"y":388.12},{"x":38,"y":388.76},{"x":40,"y":388.15},{"x":42,"y":388.26},{"x":44,"y":388.09},{"x":46,"y":388.58},{"x":48,"y":386.85},{"x":50,"y":388.23},{"x":52,"y":388.16},{"x":54,"y":388.83},{"x":56,"y":388.79},{"x":58,"y":388.74},{"x":60,"y":388.78},{"x":62,"y":388.54},{"x":64,"y":388.36},{"x":66,"y":388.7},{"x":68,"y":388.54},{"x":70,"y":388.02},{"x":72,"y":388.05},{"x":74,"y":388.31},{"x":76,"y":388.65},{"x":78,"y":388.98},{"x":80,"y":387.78},{"x":82,"y":389.42},{"x":84,"y":388.86},{"x":86,"y":388.66},{"x":88,"y":388.51},{"x":90,"y":388.27},{"x":92,"y":389},{"x":94,"y":387.8},{"x":96,"y":388.18},{"x":98,"y":388.66}]},{"key":"IDNB","values":[{"x":1,"y":387.33},{"x":3,"y":388.5},{"x":5,"y":387.75},{"x":7,"y":387.98},{"x":9,"y":388.57},{"x":11,"y":388.23},{"x":13,"y":387.83},{"x":15,"y":388.31},{"x":17,"y":388.99},{"x":19,"y":388.7},{"x":21,"y":388.49},{"x":23,"y":388.21},{"x":25,"y":388.4},{"x":27,"y":389.05},{"x":29,"y":388.26},{"x":31,"y":387.88},{"x":33,"y":388.2},{"x":35,"y":388.3},{"x":37,"y":388.08},{"x":39,"y":388.29},{"x":41,"y":388.04},{"x":43,"y":387.91},{"x":45,"y":388.23},{"x":47,"y":388.47},{"x":49,"y":386.83},{"x":51,"y":387.55},{"x":53,"y":388.03},{"x":55,"y":388.98},{"x":57,"y":388.7},{"x":59,"y":388.94},{"x":61,"y":388.47},{"x":63,"y":388.5},{"x":65,"y":387.66},{"x":67,"y":388.17},{"x":69,"y":388.29},{"x":71,"y":387.73},{"x":73,"y":388},{"x":75,"y":388.36},{"x":77,"y":388.35},{"x":79,"y":388.75},{"x":81,"y":387.36},{"x":83,"y":389.32},{"x":85,"y":388.74},{"x":87,"y":388.86},{"x":89,"y":388.57},{"x":91,"y":388.21},{"x":93,"y":388.74},{"x":95,"y":387.84},{"x":97,"y":388.18},{"x":99,"y":388.7}]}] Here is the PHP im using to make the data from a query $lrs = CDB::ExecuteQuery($sql); if($lrs) { $jsonData = convert($lrs); } function convert($lrs) { $i = 0; $intermediate = array(); while ($vals = CDB::GetAssoc($lrs)) { $key = $vals['VARIABLE']; $x = $i; $y = $vals['VAR_MEASURE_1']; $intermediate[$key][] = array('x' => $x, 'y' => $y); $i++; } $output = array(); foreach($intermediate as $key => $values) { $output[] = array( "key" => $key, 'values' => $values ); } return json_encode($output, JSON_NUMERIC_CHECK); } can anyone point me in the right direction?
  4. Hi, I'm absolutely stuck with this piece of code, I've searched and searched to get it working and have failed miserably. It also doesn't help that I'm brand new to php My Json output currently looks like this [ { "key": "OWM1", "values": [ [ "x : EW", "y :4" ], [ "x : RSE", "y :3" ], [ "x : SWE", "y :2" ], [ "x : WTE", "y :1" ], [ "x : WWE", "y :1" ] ] }, { "key": "OWM2", "values": [ [ "x : EW", "y :4" ], [ "x : RSE", "y :2" ], [ "x : SWE", "y :1" ], [ "x : WTE", "y :3" ], [ "x : WWE", "y :2" ] ] } ] But I need it to look like this for the sake of NVD3 chart to be able to process it correctly. [ { "key": "OWM1", "values": [ { x : "EW", y : 4 }, { x : "RSE", y : 3 }, { x : "SWE", y : 2 } { x : "WTE", y : 1 } { x : "WWE", y : 21 } ] }, { key: "OWM2", values: [ { x : "EW", y : 4 }, { x : "RSE", y : 2 }, { x : "SWE", y : 1 } { x : "WTE", y : 3 } { x : "WWE", y : 2 } ] }] Here is my PHP code that I am producing the first output of json with. $result = mysqli_query($con,"SELECT CODE, _POS, COUNT(CODE) AS COUNT from defects WHERE FPOS IN ('OWM1','OWM2') GROUP BY POS, CODE"); if($result) { $jsonData = convert($result); } function convert($result) { $intermediate = array(); while($rows = mysqli_fetch_assoc($result)) { $key = $rows['POS']; $x = $rows['CODE']; $y = $rows['']; $intermediate[$key][] = array('x : ' .$x,'y :' . $y); } $output = array(); foreach($intermediate as $key => $values) { $output[] = array( "key" => $key, 'values' => $values ); } echo json_encode($output); } mysqli_close($con); Is there any way anyone could help me manipulate the code I have to look exactly like the second set of JSON code that is compatible with NVD3 charts? Thanks alot.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.