Jump to content

RandomDNA

New Members
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral

About RandomDNA

  • Rank
    Newbie
  1. Gives an error: Fatal error: Call to a member function close() on a non-object
  2. I got it <?php $search_value=$_POST["search"]; $mysqli = new mysqli('localhost','root','usbw','mydb'); $myArray = array(); if ($result = $mysqli->query("SELECT * FROM transcriptome WHERE genename LIKE '%$search_value%'")) { while($row = $result->fetch_array(MYSQL_ASSOC)) { $myArray = $row; } //file_put_contents('jsonoutput.json', json_encode($myArray)); $json = json_encode($myArray); $array = json_decode($json, true); $new_array = array(); foreach( $array as $key => $value ){ $newarray[] = array($key=>$value); } echo json_encode($newarray); } $result->close(); $mysqli->close(); ?>
  3. This format is required for a barchart
  4. Thanks requinix and Sepodati for your replies I'm still figuring out how the script should be? Should i "load" the query in the $newarray? I'm sorry for my low understanding...
  5. Hi, I'm new to PHP and JSON and I'm wondering how i could change my output from: [{"genename":"xkr4","TA11MEAN":"974.25","TA11STD":"99.0085223605","TA21MEAN":"710.75","TA21STD":"115.79831605","TA22MEAN":"736.5","TA22STD":"115.79831605","TA23MEAN":"903.75","TA23STD":"107.283211641","TB11MEAN":"799.25","TB11STD":"97.2660655111","TB21MEAN":"658","TB21STD":"91.7959694104","TB22MEAN":"592.75","TB22STD":"70.9379129944","TB23MEAN":"864","TB23STD":"92.7280971443"}] to: [{"genename":"xkr4"},{"TA11MEAN":"974.25"},{"TA11STD":"99.0085223605"},{"TA21MEAN":"710.75"},{"TA21STD":"115.79831605"},{"TA22MEAN":"736.5"},{"TA22STD":"115.79831605"},{"TA23MEAN":"903.75"},{"TA23STD":"107.283211641"},{"TB11MEAN":"799.25"},{"TB11STD":"97.2660655111"},{"TB21MEAN":"658"},{"TB21STD":"91.7959694104"},{"TB22MEAN":"592.75"},{"TB22STD":"70.9379129944"},{"TB23MEAN":"864"},{"TB23STD":"92.7280971443"}] My script: <?php $search_value=$_POST["search"]; $mysqli = new mysqli('localhost','admin','pass','mydb'); $myArray = array(); if ($result = $mysqli->query("SELECT * FROM transcriptome WHERE genename LIKE '%$search_value%'")) { while($row = $result->fetch_array(MYSQL_ASSOC)) { $myArray[] = $row; } file_put_contents('jsonoutput.json', json_encode($myArray)); echo json_encode($myArray); } $result->close(); $mysqli->close(); ?> Thanks in advance
×
×
  • 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.