I have a php page as below:
$sql = "select code as ref, size from product";
$result = mysql_query($sql);
while($rs=mysql_fetch_assoc($result)){
$test[] = $rs;
}
$output['data'][] = $test;
echo json_encode( $output );
This ouputs the following:
{"data":[[{"ref":"ABC","size":"Large"},{"ref":"123","size":"Medium"}]]}
I need to modify the php, so that I can prefix some characters before the ref value so eg:
ref: ABC should be M-ABC
and
ref: 123 should be M-123
Finally I would also like to add an additional item to the array such as description and this will have a fixed description such as “This product is available in Large” (The value is based on the size).
Thanks
1 Answer