<?php $num = 0; $arrmsg1[0] = 0; foreach ($arrmsg as $value) { $arrmsg1[$num] = $value; $num++; if ($num == ($Param['page']-1)*5+4) break; } var_dump ($arrmsg1); ?> The var dump shows that there is only one element in the $ arrmsg1 array — 0; How can one either interrupt foreach without losing data on the nth iteration or iterate from the nth element?
Update
There is a list of users with whom there was a correspondence,
$Param1 = "SELECT `from`, `to` FROM `messages` WHERE `to` = '$_SESSION[USER_LOGIN]' OR `from` = '$_SESSION[USER_LOGIN]'"; $Param2 = '/messages/main/page/'; $Result = mysqli_query($CONNECT, $Param1); $n[0] = 0; while ($Row = mysqli_fetch_assoc($Result)) { If ($Row['from'] == $_SESSION['USER_LOGIN']) $arrmsg[$n] = $Row['to']; else $arrmsg[$n] = $Row['from']; $n[0]++; } $arrmsg = array_unique($arrmsg); It is necessary to bring them to 5 per page.
SELECT distinct if (to = '$_SESSION[USER_LOGIN]', from, to) as user FROM messages WHERE to = '$_SESSION[USER_LOGIN]' OR from = '$_SESSION[USER_LOGIN]' limit 5 offset 5and standard pagination. - Petty