Endlosschleife: Helfendes Auge für eine While-Schleife

XMagic

Grünschnabel
Zuerst möchte ich meinen Code ein wenig erläutern.
Ich möchte so eine News erstellen, dass er nur die ersten 500 Zeichen bzw. nur die ersten 5XX Zeichen bis zum Satzende anzeigt und dann auf "Mehr" geklickt werden muss.
Dazu hatte ich auch eine blendende Idee, doch irgendwie wird eine endlos Schleife erzeugt.
Ich sehe keinen Fehler im Code, Bitte um Hilfe!
PHP:
 $result=mysql_query("SELECT * FROM news WHERE topnews = 'yes' ORDER BY id DESC limit 1");
 while($zeile=mysql_fetch_array($result))
 	{	
 		$normtext=$zeile[text];
 		$i=0;
 		
 		while($i < 500)
 			{
 			$toptext=$toptext.$normtext[$i];
 			$i++;
 			while($i >= 500) // ohne diese While-Schleife klappt es
 				{
 		    	if($toptext[$i] == ".") // müsste er doch erkennen, oder?
 					{
 					$toptext=$toptext.$normtext[$i];
 					$i=1;
 					}
 		    	if($toptext[$i] == "!") // müsste er doch erkennen, oder?
 					{
 					$toptext=$toptext.$normtext[$i];
 					$i=1;
 					}
 		    	if($toptext[$i] == "?") // müsste er doch erkennen, oder?
 					{
 					$toptext=$toptext.$normtext[$i];
 					$i=1;
 					}
 				else
 					{
 					$toptext=$toptext.$normtext[$i];
 					$i++;
 					}
 
 				}
 			}
Danke schonmal im Voraus!
 
Stimmt, du hast Recht!
Aber der Fehler besteht immernoch.
Hier der Code:
PHP:
 $result=mysql_query("SELECT * FROM news WHERE topnews = 'yes' ORDER BY id DESC limit 1");
 while($zeile=mysql_fetch_array($result))
 	{	
 		$normtext=$zeile[text];
 		$i=0;
 		
 		while($i < 500)
 			{
 			$toptext=$toptext.$normtext[$i];
 			$i++;
 			while($i >= 500)
 				{
 				if($normtext[$i] == ".")
 					{
 					$toptext=$toptext.$normtext[$i];
 					$i=1;
 					}
 				if($normtext[$i] == "!")
 					{
 					$toptext=$toptext.$normtext[$i];
 					$i=1;
 					}
 				if($normtext[$i] == "?")
 					{
 					$toptext=$toptext.$normtext[$i];
 					$i=1;
 					}
 				else
 					{
 					$toptext=$toptext.$normtext[$i];
 					$i++;
 					}
 
 				}
 			}
 
Zurück