Answer the question
In order to leave comments, you need to log in
How to make pagination while iterating over an array?
Good afternoon!
I am learning to work with php.
There is a formed array with comments.
The output from the array is done using foreach.
Tell me, please, I can’t figure it out in any way, how can I make pagination for the displayed elements from this array?
Pagination by means of for is clear to me, but I can’t figure out what to do in my case.
Piece of code:
<tbody>
<? if ($arDoneComments){
foreach ($arDoneComments as $aws) {
$creator = CUser::GetByID($aws['CREATED_BY'])->fetch();
$corder["ID"] = $aws["id"];
?>
/*---дальше код, впринципе не интересен, тут верстка, но на всякий случай оставлю---*/
<tr id="review-<?=$aws['ID']?>" class="review-item order-item viewed-row" data-id="<?=$aws['ID']?>" onclick="">
<td class="rew-avatar">
<div class="user_avatar">
<a target="_blank" href="/user/<?= $creator['ID']; ?>">
<img style="margin:0;" class="img-circle" alt="logo" src="<?= (($aws['CLIENT_PHOTO'])? $aws['CLIENT_PHOTO']['src'] : '/bitrix/templates/topsend/img/no_avatar.png' );?>">
</a>
</div>
</td>
<td class="rew-user">
<span class="user_login break"><a target="_blank" href="/user/<?= $creator['ID']; ?>"><?=$creator['UF_FIO']?></a></span><br/>
<span>
<small>
<?=$aws['TIMESTAMP_X']?>
</small>
</span>
</td>
<td class="rew-txt">
<div class="comment_desc">
<?=$aws['PREVIEW_TEXT']; ?>
</div>
</td>
<td class="rew-ord">
<div class="user_login"><a href="/order/<?=$aws["PROP"]["connect_order"]["VALUE"]; ?>">#<?=$aws["PROP"]["connect_order"]["VALUE"]; ?></a></div>
</td>
<td class="rew-rait">
<?//pr($aws['PROP']);?>
<?if($aws['PROP']['int_positive']['VALUE']==1):?>
<div class="raets_img_good"></div>
<?else:?>
<div class="raets_img_bad"></div>
<?endif?>
</td>
</tr>
<tr style="height:0;" class="hide order-info">
<td style="height:0;padding:0;" colspan="5"></td>
</tr>
<tr></tr>
<?}?>
<?}else{?>
<tr>
<td colspan="4" class="text-center">
Нет ни одного отзыва
</td>
</tr>
<? } ?>
</tbody>
Answer the question
In order to leave comments, you need to log in
In your case, nothing .. I apologize for being a little off topic, but I strongly recommend that you, since you contacted Bitrix (I think this is justified), take courses on their website. There, everything is chewed in as much detail as possible .. It just makes no sense what you are doing, learn to do it right away. Below is a link for navigation, but you need to redo everything..
Here is the link
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question