Guten Abend,
mein aktuelles Problem ist folgende und zwar Versuch ich Daten mittels PHP und MySQL in einem JSON Format zu generieren wie das JSON Format aussehen soll befindet sich bei "Ziel Format", aktuell bin ich dabei alle UID's die sich in der Spalte UID befinden sich dann spezifisch an dem Array Index 'uids' mit dem Separator , zu inserten, dasselbe Spiel nochmal dann bei PID & Since, danach soll es in diesem JSON Format konvertiert werden.
{"uids":"688503066529759252, 1236099216917528666, 1065224224224063488, 282859044593598464, 159985870458322944, 235148962103951360","pids":"1155519336052699277, 1225060204777967747, 810918366045798451, 810540985032900648, 155149108183695360, 270904126974590976","since":"2024-12-14 06:18:12, 2025-02-03 23:48:56, 2025-02-04 22:25:02, 2025-02-04 22:52:28, 2025-02-04 22:53:09, 2025-02-04 22:54:54"}
So sieht es aktuell aus.
{"uids":"68850306652975925212360992169175286661065224224224063488282859044593598464159985870458322944235148962103951360","pids":"11555193360526992771225060204777967747810918366045798451810540985032900648155149108183695360270904126974590976","since":"2024-12-14 06:18:122025-02-03 23:48:562025-02-04 22:25:022025-02-04 22:52:282025-02-04 22:53:092025-02-04 22:54:54"}
Der PHP Code:
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
if(!empty(ctype_digit(strval($_GET['gid'])))) {
require_once('mysqlConf.php');
$guildid = $_GET['gid'];
if($exec = $dbhandle->prepare("SELECT `UID`, `PID`, `Since` FROM `user_couples` WHERE `GID` = :gid ORDER BY `Since`")) {
$exec->execute(array('gid' => $guildid));
header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');
$array1 = ['uids' => ''];
$array2 = ['pids' => ''];
$array3 = ['since' => ''];
while($row = $exec->fetch(PDO::FETCH_OBJ)) {
$array1['uids'] .= $row->UID;
$array2['pids'] .= $row->PID;
$array3['since'] .= $row->Since;
}
$json = $array1 += $array2 += $array3;
echo json_encode($json);
}
return true;
}
?>
Alles anzeigen
Mit freundlichen Grüßen
Settings