armasmike
asked on
How to export all my data in to a json array
How to export all my data in to a json array
Here is my code
How can I put all the data it gets in to a json array. I have attached a file of the output data. What-i-want-it-to-be.xlsx
How can I put this in a json array ?
Here is my code
<?php
ini_set('display_errors', TRUE);
error_reporting(E_ALL);
if(isset($_POST['submit']))
{
$UsrWorkOrder = $_POST['Work_Order'];
//db connect info
include 'conn.php';
//Where the query are stored
include 'Query.php';
$result_Vis = odbc_exec($conn_Vis,$sql_Vis); // Get Data From Result
while($row2 = odbc_fetch_array($result_Vis))
{
//Store the data in the new array
$result_cor1db01_2 = odbc_exec($conn_cor1db01_2,$sql_cor1db01_2); // Get Data From Result
while($row3 = odbc_fetch_array($result_cor1db01_2))
{
//This stores the data
$Barcode = $row3["Work Order No"]."-". $row3["Serial No"];
$part = $row2["PART_X"];
$DESCR = $row2["DESCR_X"];
$Cable_Length = $row3["ValueInches"];
$MFG = $row3["Work Order No"]."-". $row3["Serial No"];
$Test_A = number_format($row3["Value1"],2);
$Test_B = number_format($row3["Value2"],2);
Echo "<br><br><img src=barcode.php?codetype=Code128B&size=80&text=".$row3["Work Order No"]."-". $row3["Serial No"] ." />";
Echo "<br>".$row3["Work Order No"]."-". $row3["Serial No"]."<br>";
Echo "Part Number: ".$part."<br>";
Echo "Description: " .$DESCR."<br>";
Echo "Mfg Lot Number: " .$row3["Work Order No"]."-". $row3["Serial No"]."<br>";
Echo "Cable Length: ". $row3["ValueInches"]."<br>";
Echo "Test Results: ".substr($row3["SS1"], -1)." " .number_format($row3["Value1"],2)."<br>";
Echo "Test Results: ".substr($row3["SS2"], -1)." " .number_format($row3["Value2"],2)."<br>";
}
}
odbc_close($conn_cor1db01_2);
odbc_close($conn_Vis);
}
?>
How can I put all the data it gets in to a json array. I have attached a file of the output data. What-i-want-it-to-be.xlsx
How can I put this in a json array ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That worked great !
ASKER
Well that's only getting the info from 1 query I have two query's
I have a row3 and row2
I have a row3 and row2
ASKER
this is all the info I need to go in the json array
are the only 2 from other db server
$Barcode = $row3["Work Order No"]."-". $row3["Serial No"];
$part = $row2["PART_X"];
$DESCR = $row2["DESCR_X"];
$Cable_Length = $row3["ValueInches"];
$MFG = $row3["Work Order No"]."-". $row3["Serial No"];
$Test_A = number_format($row3["Value1"],2);
$Test_B = number_format($row3["Value2"],2);
$part = $row2["PART_X"];
$DESCR = $row2["DESCR_X"];
are the only 2 from other db server
ASKER
it doesn't like it if I do
$json []= "barcode" => $Barcode = $row3["Work Order No"]."-". $row3["Serial No"]
ASKER
I got it working
ASKER
Open in new window