簡単なプレゼンテーションを行い、mysql からテキストと画像を取得しました。たとえば、1 つのテキストと 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
---------- ----------------
これが問題です 。2 番目と 3 番目のスライドから重複したテキストを削除したいのです。これは私のコードです
$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;
}
```