Ich möchte den Fehler von Undefined Offset, natürlich am besten, wenn es gelöst werden könnte.PHP-Fehler ausblenden/Fehler zu lösen Undefined Offset
Der Code zeigt die Bilder, die ich wollte. (3 Bilder pro Seite). Klicken Sie auf Seite 1 zeigt das Bild mit der Nummer 001002003 Seite 2 zeigt das Bild mit der Nummer 004005006 etc ....
Meine Codes
$catCode = isset($_GET["cat"]) ? $_GET["cat"] : "ac"; //getting url
$upperCatCode = strtoupper($catCode);
$arr = [];
//to get my images based on their image number
foreach ($productArr[$catCode] as $imgNumber => $productDetail) {
array_push($arr, $imgNumber);
$imgNumber = $arr;
}
echo"<div align='center'>
<ul class='pagination'>";
// getting the total pages I need for the category if i want to display 3 images per page
for ($i = 1; $i < count($productArr[$catCode])/3 + 1; $i++) {
echo"<li><a href='http://localhost/ca1/collectionPage.php?cat={$catCode}&page={$i}'> {$i}</a></li>
";
}
echo"<li><a href='http://localhost/ca1/collectionSummary.php?cat={$catCode}'>view all</a></li>";
echo"</ul>
</div>";
// the loop i used to loop through the images
for ($i = 0; $i < count($productArr[$catCode]); $i++) {
// count the total number of images
$total = count($arr);
// limit the number of images shown
$limit = 3;
//calculate the total number of pages
$totalPages = ceil($total/$limit);
$page = max($page, 1); //get 1 page when $_GET['page'] <= 0
$page = min($page, $totalPages); //get last page when $_GET['page'] > $totalPages
$offset = ($page - 1) * $limit;
if($offset < 0) {$offset = 0;}
$newArr = array_slice($arr, $offset, $limit);
echo "<div class='col-md-4'>
<div class='thumbnail'>
<a href='http://localhost/ca1/collectionDetail.php?cat={$catCode}&itemCode={$newArr[$i]}'><img class='img-responsive image_size' src='images/$catCode/row_{$catCode}{$newArr[$i]}_m0.jpg'></a>
<div class='caption'>
<p align='center'><b>Model No.Row-{$upperCatCode}-{$newArr[$i]}</b></p>
</div>
</div>
</div> ";
Welche Zeile ist '145'? – C2486
können Sie bitte eine Geige erstellen, wenn möglich, damit wir sie bei Bedarf ändern können. –
@Rishi Linie 145: '' Es ist die Schleife – aaa