I am fetching a data according to the table name, but I also need to send the table name to the front end along with the data. I have this code.
$sql_fetchItems = "select * from `$cat`";
$result_fetchItems = mysqli_query($connection, $sql_fetchItems);
for ($j; $j < mysqli_num_rows($result_fetchItems); $j++) {
echo ($j > 0 ? ',' : '') . json_encode(mysqli_fetch_object($result_fetchItems));
}
where the objects will be encoded and sent to the front-end. if I add ",{$cat}" within the for
statement, it will become another object of course. But is there a way to send the table name along with the object? Like in the JS console, it should receive {"name": "1", "category", "something", "something": "something"}
?