I have searched for weeks for an answer to this I have json data that I need to echo to the page and to auto fill a form based on the button pushed next to that name. here is a list of code that I have Json
$url = 'http://***.***.***.***:30120/players.json';
// path to your JSON file
$data = file_get_contents($url);
// put the contents of the file into a variable
$players = json_decode($data); // decode the JSON feed
<?php foreach ($players as $players) : ?>
<tr>
<td>
<button>Ban</button>
<td input type="hidden" name="user" value="user"><?php echo $players->name; ?></td>
<td input type="hidden" name="id0" value="id0"><?php echo $players->identifiers[0]; ?></td>
<td input type="hidden" name="id1" value="id1"><?php echo $players->identifiers[1]; ?></td>
</td>
</tr>
<?php endforeach; ?>
Gives me this
https://gyazo.com/e72aee4c977e9226f2de3a2053f89c2f
and I want it to auto fill a form with the players name.
or something like this
function getpnames()
{
$url = 'http://***.***.***.***:30120/players.json'; // path to your JSON file
$data = file_get_contents($url); // put the contents of the file into a variable
$players = json_decode($data); // decode the JSON feed
$site = BASE_URL;
$result = json_decode($data);
echo '
<table id="allUsers" class="table table-striped table-bordered">
<thead>
<tr>
<th>Steam ID</th>
<th>License</th>
<th>Banned Player</th>
<th>Admin</th>
<th>Reason</th>
<th>Date</th>
<th>Perm?</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
';
while ($row = http_build_query($result, '', ';'))
{
echo '
<tr>
<td>' . $row[1] . '</td>
<td>' . $row[2] . '</td>
<td>' . $row[3] . '</td>
<td>' . $row[4] . '</td>
<td>' . $row[5] . '</td>
<td>' . $row[6] . '</td>
<td>' . $row[7] . '</td>
<td>
<form action="'.$site.'/actions/adminActions.php" method="post">
<input name="deleteBan" type="submit" class="btn btn-xs btn-link" onclick="deleteBan(' . $row[0] . ')" value="Delete" />
';
echo '
<input name="bid" type="hidden" value=' . $row[0] . ' />
</form>
</td>
</tr>
';
}
echo '
</tbody>
</table>
';
}
I cant seem to wrap my head around this
Json Data
[{"endpoint":"127.0.0.1","id":206,"identifiers":["steam:1100001366011b6","license:"],"name":"Bonsan905","ping":21},{"endpoint":"127.0.0.1","id":183,"identifiers":["steam:11000010b7f88b5","license:","xbl:2535467507102211","live:844425221417841"],"name":"Jonathan J.","ping":34},{"endpoint":"127.0.0.1","id":190,"identifiers":["steam:110000110be22ca","license:","xbl:2535451382352605","live:1899947295907508"],"name":"[TT-AMRA III] Aqua","ping":47},{"endpoint":"127.0.0.1","id":135,"identifiers":["steam:1100001161c23dc","license:","xbl:2535429725972000","live:914802232166266"],"name":"Norank.","ping":19},{"endpoint":"127.0.0.1","id":160,"identifiers":["steam:110000106d4e97c","license:","xbl:2535436731105061","live:844428383945858"],"name":"Max W.","ping":66},{"endpoint":"127.0.0.1","id":181,"identifiers":["steam:11000010a812251","license:","xbl:2535415227958286","live:1688853869063259"],"name":"Filippen","ping":40},{"endpoint":"127.0.0.1","id":202,"identifiers":["steam:110000134bddbd7","license:","xbl:2535453098180945","live:914802201806712"],"name":"VAC_brotha","ping":44},{"endpoint":"127.0.0.1","id":243,"identifiers":["steam:1100001351ef803","license:","xbl:2533274991210897","live:985156970449557"],"name":"Allan [S-662]","ping":177},{"endpoint":"127.0.0.1","id":218,"identifiers":["steam:11000010ad8b0bf","license:","xbl:2533274880694377","live:1759221802890599"],"name":"Katie Kat","ping":166},{"endpoint":"127.0.0.1","id":184,"identifiers":["steam:11000010be231cc","license:","xbl:2533275012889196","live:1759222203382981"],"name":"High Budget Trucker T-69","ping":55},{"endpoint":"127.0.0.1","id":244,"identifiers":["steam:110000115f03632","license:"],"name":"John Adams","ping":72},{"endpoint":"127.0.0.1","id":223,"identifiers":["steam:11000010bb69ddd","license:","live:1899943264922053"],"name":"[S853] Johnathen [1Z13]","ping":45},{"endpoint":"127.0.0.1","id":216,"identifiers":["steam:11000011cb29587","license:"],"name":"Steve","ping":198},{"endpoint":"127.0.0.1","id":203,"identifiers":["steam:1100001076829a3","license:","xbl:2535446122759170","live:1055521739595821"],"name":"Hoopsure","ping":152},{"endpoint":"127.0.0.1","id":226,"identifiers":["steam:1100001359fd857","license:"],"name":"[S-894] EpicDogePlayzYT","ping":183},{"endpoint":"127.0.0.1","id":236,"identifiers":["steam:11000010d29c185","license:"],"name":"Night","ping":24},{"endpoint":"127.0.0.1","id":193,"identifiers":["steam:1100001183e1fa8","license:"],"name":"J.W","ping":201},{"endpoint":"127.0.0.1","id":219,"identifiers":["steam:11000013559122f","license:"],"name":"[S-885]Damien.B","ping":61},{"endpoint":"127.0.0.1","id":187,"identifiers":["steam:110000108413e7a","license:","xbl:2535423985280873","live:985156647647394"],"name":"Purple Deathh","ping":18},{"endpoint":"127.0.0.1","id":130,"identifiers":["steam:110000113e184ad","license:","xbl:2535441445938947","live:844428429722616"],"name":"JamiDoesStuff","ping":23},{"endpoint":"127.0.0.1","id":205,"identifiers":["steam:11000011a84d2dc","license:"],"name":"Johnny","ping":45},{"endpoint":"127.0.0.1","id":231,"identifiers":["steam:1100001065ace8a","license:"],"name":"unicornassassin","ping":147},{"endpoint":"127.0.0.1","id":166,"identifiers":["steam:110000113334071","license:","xbl:2535468344890625","live:1759222493808119"],"name":"ItsQeeqo","ping":21},{"endpoint":"127.0.0.1","id":225,"identifiers":["steam:1100001119c6bdc","license:"],"name":"Pizza Parker","ping":74},{"endpoint":"127.0.0.1","id":238,"identifiers":["steam:110000117829c82","license:","xbl:2535428445779911","live:914801662046383"],"name":"Peraergold","ping":92},{"endpoint":"127.0.0.1","id":186,"identifiers":["steam:11000010582ce53","license:"],"name":"Danni Dank","ping":41},{"endpoint":"127.0.0.1","id":241,"identifiers":["steam:1100001097779e3","","xbl:2533275032997544","live:844428204995039"],"name":"Tony J.","ping":203},{"endpoint":"127.0.0.1","id":240,"identifiers":["steam:110000112553cd6","license:","xbl:2535471542971056","live:914801366308041"],"name":"Lassen","ping":60},{"endpoint":"127.0.0.1","id":150,"identifiers":["steam:110000110d1cebc","license:","live:844428721915290"],"name":"5D|155 Edward Johnson","ping":47},{"endpoint":"127.0.0.1","id":220,"identifiers":["steam:1100001186378bc","license:","xbl:2535439158130935","live:1759221955842916"],"name":"Sync","ping":81},{"endpoint":"127.0.0.1","id":215,"identifiers":["steam:11000010b2f22a8","license:"],"name":"Thomas W. | CIV-335","ping":50},{"endpoint":"127.0.0.1","id":213,"identifiers":["steam:11000010b196656","license:"],"name":"Birac","ping":66}]
</div>