Add the mid-cycle element
-
Hello, how can the mid-cycle element be added and further implemented. This is the example of the cycle:
while ($date= $sql->fetch()) { //цикл 1 выводит 10 записей echo $date['title']; echo $date['img']; echo $date['text']; } while ($rekl= $sqlrekl->fetch()) { //цикл 2 выводи записи echo $date['title']; echo $date['img']; echo $date['text']; }
In the middle of its implementation, another cycle should be set up, followed by the continuation of the first. Example of implementation:
Запись1 .. Запись5
//Второй цикл
Запись6
..
Запись10
-
Let's say that pdo is what it is.
$date = $sql->fetch(); $dataArray = iterator_to_array($date);
for($i=0;$i<count($dataArray);$i++) {
echo $dataArray[$i]['title'];
// etc ....
if($i==cail(count($dataArray)/2)) {
while ($rekl= $sqlrekl->fetch()) { //цикл 2 выводи записи
echo $rekl['title']; // тут я думаю ошибка по этому date на rekl
echo $rekl['img'];
echo $rekl['text'];
}
}
}