lorsque j'inclue for dans while j'obtiens seulement le premier résultat
comment faire pour obtenir toute la table svp?
Code : Tout sélectionner
$posts = array();
$posts[] = array('status' => 'ok');
$seenbydata = array();
while ($row = $result->fetch_assoc()) {
$msgid = $row['id'];
$msgdate = $row['date'];
$sendby = $row['sendby'];
$sendto = $row['sendto'];
$message = $row['message'];
$sendername = $row['sendername'];
$attach = $row['file'];
$msgdateago = timeago($msgdate);
$seenby = json_decode($row['seenby']);
for ($i = 0; $i < count($seenby); $i++) {
$seenid = $seenby[$i];
$sql = "SELECT CONCAT(users.prenom, ' ', users.nom) AS name FROM users WHERE identifiant = '$seenid'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$seenbydata[] = array('seenby' => array(
'id' => $seenid,
'name' => $row['name']
));
}
}
}
$posts[] = array(
'convdata' => array(
'msgid' => $msgid,
'msgdate' => $msgdate,
'msgdateago' => $msgdateago,
'seen' => $seenbydata,
'sendby' => $sendby,
'sendto' => $sendto,
'message' => $message,
'attach' => $attach,
'sendername' => $sendername
)
);
}j'encode le tout en json