我做了一个简单的演示,并从 mysql 获取文本和图像。例如,我有一个文本和 5 个图像。每张幻灯片必须有 2 张图片。但问题是每张幻灯片上的 while 循环中的文本都重复。
例子:
This is how it works now: I want this:
----------- ----------------
Slide1 Slide1
text 1 text 1
2 images 2 images
----------- ----------------
----------- ----------------
Slide2 Slide2
text 1
2 images 2 images
----------- ----------------
----------- ----------------
Slide3 Slide3
text2
1 image 1 image
---------- ----------------
这就是问题所在: 我想从第二张和第三张幻灯片中删除重复的文本。这是我的代码
$brojacslikapostrani = 0;
$query1 = "SELECT izvestaji.operacija, izvestaji.ucinak, izvestaji.id, operacije.nazivEng FROM izvestaji INNER JOIN operacije ON izvestaji.operacijaId=operacije.id WHERE izvestaji.datum='$datum' AND izvestaji.projekatId='$projekatId'";
$result1 = mysqli_query($con, $query1);
while ($row = mysqli_fetch_array($result1)) {
$id = $row['id'];
$query2 = "SELECT img_name FROM slike WHERE izvestajId='$id' AND datum='$datum'";
$result2 = mysqli_query($con, $query2);
while ($row2 = mysqli_fetch_array($result2)) {
if ($brojacslikapostrani % 2 == 0) {
$currentSlide = createTemplatedSlide($objPHPPresentation);
//Pozadina
$oBkgImage = new Image();
$oBkgImage->setPath('./resources/background.png');
$currentSlide->setBackground($oBkgImage);
$shape = $currentSlide->createRichTextShape();
$shape->setHeight(100)
->setWidth(930)
->setOffsetX(10)
->setOffsetY(20);
$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
$textRun = $shape->createTextRun(strtoupper($row['nazivEng']));
$textRun->getFont()->setBold(true)
->setSize(48)
->setName('Times New Roman')
->setColor($colorBlack);
// ----------- THIS CODE MAKES THE PROBLEM ------------------------
echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
$shape = $currentSlide->createRichTextShape()
->setHeight(600)
->setWidth(930)
->setOffsetX(10)
->setOffsetY(130);
$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT)
->setMarginLeft(25)
->setIndent(-25);
$shape->getActiveParagraph()->getFont()->setSize(20)
->setName('Times New Roman')
->setColor($colorBlack);
$shape->getActiveParagraph()->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET);
$shape->createTextRun($row['operacija'])->getFont()->setBold(true);
$shape->createTextRun(": ")->getFont()->setBold(true);
$shape->createTextRun($row['ucinak']);
//------------------------------------------------------------------------
$shape1 = $currentSlide->createDrawingShape();
$shape1->setName('Part page');
$shape1->setDescription('Page');
$shape1->setPath('../../../../files/izvestaji/' . $project . '/' . $datum . '/' . $row['nazivEng'] . '/' . $row2['img_name']);
$shape1->setResizeProportional(false);
$shape1->setOffsetX(75);
$shape1->setOffsetY(300);
$shape1->setHeight(400);
$shape1->setWidth(400);
} else {
$shape1 = $currentSlide->createDrawingShape();
$shape1->setName('Part page');
$shape1->setDescription('Page');
$shape1->setPath('../../../../files/izvestaji/' . $project . '/' . $datum . '/' . $row['nazivEng'] . '/' . $row2['img_name']);
$shape1->setResizeProportional(false);
$shape1->setOffsetX(495);
$shape1->setOffsetY(300);
$shape1->setHeight(400);
$shape1->setWidth(400);
}
$brojacslikapostrani++;
}
$brojacslikapostrani = 0;
}
```