Click here to Skip to main content
14,920,374 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My code is this:
<html>
<head><title>Kundenliste</title>
</head>
<body>
<p> Wichtige Kunden unserer Bücherhalle:</p>
<?php $liste = array("Ackermann", "Levi", "A80 153 635 0", "Erwachsener","leviackermann.erwinpeepee@gmail.com","InselParadis 35 84321 Paradis",
                      "Jäger", "Eren",  "A80 152 634 0", "Jugendlicher","erenjäger.imadamikasa@gmail.com",      "InselParadis 19 84321 Paradis",
                      "Freecs", "Gon", "A80 151 633 0",   "Kind",       "gonfreecs.rockpaperscissors@gmail.com","Walinsel 12 20012 Insel",
                      "Uzumaki", "Naruto", "A80 150 632 0","Jugendlicher","uzumakinaruto.sagschonsasuke@gmail.com","Konohagakure 32 12133 Ninja",
					  "Sugawara", "Koushi", "A80 149 631 0","junger Erwachsener","koushisugawara.negativebegone@gmail.com","Miyagi 18 21310 Miyagi", )  ?>
<p> </p>
 <p>Kundenliste (Stand <?php echo strftime('%d.%m.%Y') ?>)</p>  
<font face="Calibri, Helvetica, sans-serif" size="15">
<table width="60%" border="7" cellpadding="2" cellspacing="3" bgcollor = "#2EFE2E">
  <tr bgcolor="#2EFE2E">
    <td width="15%">Name</td>
    <td width="15%">Vorname</td>
    <td width="15%">Kartennummer</td>
	<td width="20%">Vertragsart</td>
	<td width="20%">E-Mail Adresse</td>
	<td width="20%">Adresse</td>
  </tr>
  <?php for ($i = 0; $i < 6; $i++) { ?>
  <tr bordercolor="#58FAD0">
    <td> <?php echo $liste[6 * $i]     ?></td>
    <td> <?php echo $liste[6 * $i + 1] ?></td>
    <td> <?php echo $liste[6 * $i + 2] ?></td>
    <td> <?php echo $liste[6 * $i + 3] ?></td>
	<td> <?php echo $liste[6 * $i + 4] ?></td>
	<td> <?php echo $liste[6 * $i + 5] ?></td>
  </tr>
  <?php } ?>   
  </table>
</font>
</body>
</html>


and it keep saying this:
Notice: Undefined offset: 30 in C:\xampp\good\htdocs\php\c.php on line 25
	
Notice: Undefined offset: 31 in C:\xampp\good\htdocs\php\c.php on line 26
	
Notice: Undefined offset: 32 in C:\xampp\good\htdocs\php\c.php on line 27
	
Notice: Undefined offset: 33 in C:\xampp\good\htdocs\php\c.php on line 28
	
Notice: Undefined offset: 34 in C:\xampp\good\htdocs\php\c.php on line 29
	
Notice: Undefined offset: 35 in C:\xampp\good\htdocs\php\c.php 
on line 30

What I have tried:

I tried to fix it with changing the numbers in the list echo and in the array.the table is right but in the last spalte it says that
Notice: Undefined offset: 30 in C:\xampp\good\htdocs\php\c.php on line 25
	
Notice: Undefined offset: 31 in C:\xampp\good\htdocs\php\c.php on line 26
	
Notice: Undefined offset: 32 in C:\xampp\good\htdocs\php\c.php on line 27
	
Notice: Undefined offset: 33 in C:\xampp\good\htdocs\php\c.php on line 28
	
Notice: Undefined offset: 34 in C:\xampp\good\htdocs\php\c.php on line 29
	
Notice: Undefined offset: 35 in C:\xampp\good\htdocs\php\c.php 
on line 30
Posted
Updated 9-May-21 20:04pm

1 solution

Your $liste only contains 30 items:
"Ackermann"
"Levi"
"A801536350"
"Erwachsener"
"leviackermann.erwinpeepee@gmail.com"
"InselParadis3584321Paradis"
"Jäger"
"Eren"
"A801526340"
"Jugendlicher"
"erenjäger.imadamikasa@gmail.com"
"InselParadis1984321Paradis"
"Freecs"
"Gon"
"A801516330"
"Kind"
"gonfreecs.rockpaperscissors@gmail.com"
"Walinsel1220012Insel"
"Uzumaki"
"Naruto"
"A801506320"
"Jugendlicher"
"uzumakinaruto.sagschonsasuke@gmail.com"
"Konohagakure3212133Ninja"
"Sugawara"
"Koushi"
"A801496310"
"jungerErwachsener"
"koushisugawara.negativebegone@gmail.com"
"Miyagi1821310Miyagi"
PHP array indexes are zero based, to the valid values for an index to $liste are 0 to 29 inclusive.
Values of 30 and higher try to access information which doesn't exist, so you rightly get an error.

And I'd suggest that you can make your coder a lot more readable - plus much, much more reliable and maintainable - by using a class and createing an array of those instead of a linear array of mixed data ...
PHP OOP Classes and Objects[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900