Certo
Questo è lo script corretto e funzionante, server ad estrarre dati da una tabella e scriverli in un file json, utilizzabile poi per js.
codice:<?php header("Content-Type: application/json; charset=UTF-8"); $obj = json_decode($_GET["x"], false); $conn = new mysqli("localhost", "username", "password", "nomedb"); $conn->set_charset("utf8"); $stmt = $conn->prepare("SELECT ordine, cliente, dataOrdine, totalePagato, tipoPagamento, piattaforma, dataPagamento, corriere, dataSpedizione, reso, dataReso FROM portale_credito ORDER BY idPortale DESC "); $stmt->bind_param("ss",$obj->table); $stmt->execute(); $result = $stmt->get_result(); $outp = $result->fetch_all(MYSQLI_ASSOC); echo json_encode($outp); $json_data = json_encode($outp); file_put_contents('data.json', $json_data); ?>

Rispondi quotando