I'm creating a PHP to create a JSON and load a table where I can check the order records, where I have directions and directions to get separately. I want to be able to join those two columns to be able to put those results in a single column of the table when loading it. This is PHP:
<?php
function toMoney($val,$r=2)
{
error_reporting(E_ERROR | E_PARSE);
$n = $val;
$c = is_float($n) ? 1 : number_format($n,$r);
$d = '.';
$t = ',';
$sign = ($n < 0) ? '-' : '';
$i = $n=number_format(abs($n),$r);
$j = (($j = $i.length) > 3) ? $j % 3 : 0;
return $symbol.$sign .($j ? substr($i,0, $j) + $t : '').preg_replace('/(\d{3})(?=\d)/',"1" + $t,substr($i,$j)) ;
}
$hostname = "Localhost";
$username = "";
$password = "";
$database = "aabdesig_registros";
$conexion=mysqli_connect($hostname, $username, $password, $database) or die ("Problemas con la conexion");
$requestData= $_REQUEST;
$sql = "SELECT *";
$sql.=" FROM registros where estado = 'pendiente'";
$query=mysqli_query($conexion, $sql) or die("ajax-grid-data.php: get PO");
$data = array();
while( $row=mysqli_fetch_array($query) ) {
$dir = $row["dir_obra"];
$nestedData=array();
$nestedData["hora"] = $row["hora"];
$nestedData["cliente"] = $row["cliente"];
$nestedData["dir_obra"] = $dir;
$nestedData["indicaciones"] = $row["indicaciones"];
$nestedData["fecha_entrega"] = $row["fecha_entrega"];
$nestedData["resistencia"] = $row["resistencia"];
$nestedData["m3"] = $row["m3"];
$data[] = $nestedData;
}
$json_data = array("data" => $data);
echo json_encode($json_data);
?>
Try using $dir = $row["dir_obra"]."<br/>".$row["indicaciones"];
but it affects the entire structure of the JSON at the time of loading, and I just need to join both results and put them into a single variable.
Thank you in advance for your answers.