ERLEDIGT
NEIN
NEIN
ANTWORTEN
4
4
ZUGRIFFE
281
281
EMPFEHLEN
-
27.08.06 22:02 #1D@nger Tutorials.de Gastzugang
Hallo,
an folgendem Code muss irgendetwas falsch sein, denn ich bekomme eine Tabelle, in der jede Zeile gleich ist, also es sind die gleichen Datensätze. Nehme ich die for-Schleife raus funktioniert es komischerweise. Also wird das Array wahrscheinlich wieder zurückgesetzt. Kann sich das vielleicht mal jemand anschauen? Vielen Dank schon mal.
PHP-Code:
<?php
$sent = $_GET['sent'];
$ausgeben = $_GET['ausgeben'];//Inhalt der Checkboxen
if ($sent == 'yes')
{
$ausgeben_text = implode(', ',$ausgeben);
// $ausgeben_array=explode(', ',$ausgeben_text);
echo $ausgeben_text. "<br>";
// in $ausgeben_text steht 98, 99
$file = "CL_Artikelstamm.txt";
$lines = file($file);
$numlines = count($lines);
print('<table border="1" cellpadding="10" cellspacing="0" style="border-collapse: collapse"
bordercolor="#111111" height="128">');
$row = 1;
$handle = fopen ("CL_Artikelstamm.txt","r");
$id="1";
$i=0;
$d=0;
//while($id < $numlines && $id < 10) {
$ausgeben_array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
93, 94, 95, 96, 97, 98, 99, 100);
while (($data = fgetcsv ($handle, 1000, ";") AND $id < $numlines AND $id <
array_pop($ausgeben_array)+1) !== FALSE) {
$num = count ($data);
$row++;
$Bezeichnung1 = $data[2];
$Bezeichnung2 = $data[3];
$Preis = $data[7];
$Bild = $data[8];
//Get all field information out of the table
//Parse errors from the information (U
$Bezeichnung1 = str_replace("/n", "<br>", $Bezeichnung1);
$Bezeichnung2 = str_replace("/n", "<br>", $Bezeichnung2);
// $Preis = number_format($Preis, 2, ",", "");
// if ($i != 0)
// {
// $d=$i+1;
// }
for ($i; $i < sizeof($ausgeben_array); $i++)
{
if (intval($ausgeben_array[$i]) == intval($id))
{
if($Bild=="")
{
$Bild="0";
if (!file_exists("images/" . $Bild))
{
$Bild="1";
}
}
//We got all record information out!
//Example of usage:
if ($id%2==0)
{
print("<tr>");
}
else
{
print("<tr bgcolor=#CCCCCC>");
}
//Spalten
print("<td width=-6 height=44 valign=top><font face=Arial size=2> $id.<br><input
type=checkbox value=$id name=ausgeben[] checked> </font></td>");
print("<td width=108 height=44>");
if ($Bild=="1")
{
print(" <b><font face=Arial size=2>Kein Bild vorhanden</font></b> ");
}
else
{
print("<img src=images/$Bild width=150>");
}
print("</td>");
print("<td width=200 height=44 valign=top><b><font face=Arial size=2>$Bezeichnung1</b>
<br>
Best.Nr.:
<br>
$Bezeichnung2
<br>
<br>
<b>Preis: $Preis EUR</b>
</font>
</td>");
if($id=="1")
{
$id="2";
}
else
{
$id=$id+1;
}
//}
}
}
}
fclose ($handle);
print("</tr></table>");
}
?>
-
Also ich find den Code in der Form praktisch unlesbar, man kann ja garnicht sehen wo die For-Schleife wieder aufhoert.
Daher moechte ich Dich doch, auch in Deinem Interesse, bitten die Formatierung des Codes ein wenig klarer zu gestalten und nicht solche abenteuerlichen Konstrukte wie das folgende zu bieten:
Auch die vielen Leerzeilen im Code machen es nicht gerade einfacher den Ueberblick zu behalten.PHP-Code:}
}
}
fclose ($handle);
print("</tr></table>");
}
PHP Class Collection - PHP-Klassen fuer PHP 5 (und Teilweise auch fuer PHP 4)
Updates: Catcher 1.1, FTPConnection 1.2, MultiSQL 1.1, RSS2 1.1, SMTPConnection 1.4
__________________
EasyLFS - Hintergrundinformationen, Installationsanleitung, Softwareliste und Download
EasyLFS Projektthread - Informationen, Status und Diskussion zu meiner Linux-Distribution
__________________
__________________Ich bin die Schildkroete, mein Sohn. Ich habe das Universum erschaffen, aber bitte mach mir daraus keinen Vorwurf; ich hatte Bauchschmerzen.
Zitat von Friedrich Nietzsche
-
28.08.06 15:12 #3D@nger Tutorials.de Gastzugang
Hallo, danke, das hilft zwar nicht bei meinem Problem...
Gibt's ein Programm, was den Code automatisch formatiert?
-
28.08.06 15:32 #4D@nger Tutorials.de Gastzugang
Hallo, so, habe ein wirklich geniales Programm namens PSPAD gefunden, was den Code wie folgt formatiert hat:
Mir fällt aber gerade auf, dass das doch nicht so ganz stimmt. Ich korrigiere noch mal.PHP-Code:<?php
$sent = $_GET['sent'];
$ausgeben = $_GET['ausgeben'];//Inhalt der Checkboxen
if ($sent == 'yes')
{
$ausgeben_text = implode(', ',$ausgeben);
// $ausgeben_array=explode(', ',$ausgeben_text);
echo $ausgeben_text. "<br>";
// in $ausgeben_text steht 98, 99
$file = "CL_Artikelstamm.txt";
$lines = file($file);
$numlines = count($lines);
print('<table border="1" cellpadding="10" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" height="128">');
$row = 1;
$handle = fopen ("CL_Artikelstamm.txt","r");
$id="1";
$i=0;
$d=0;
//while($id < $numlines && $id < 10) {
$ausgeben_array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100);
while (($data = fgetcsv ($handle, 1000, ";") AND $id < $numlines AND $id < array_pop($ausgeben_array)+1) !== FALSE) {
$num = count ($data);
$row++;
$Bezeichnung1 = $data[2];
$Bezeichnung2 = $data[3];
$Preis = $data[7];
$Bild = $data[8];
//Get all field information out of the table
//Parse errors from the information (U
$Bezeichnung1 = str_replace("/n", "<br>", $Bezeichnung1);
$Bezeichnung2 = str_replace("/n", "<br>", $Bezeichnung2);
// $Preis = number_format($Preis, 2, ",", "");
// if ($i != 0)
// {
// $d=$i+1;
// }
for ($i; $i < sizeof($ausgeben_array); $i++)
{
if (intval($ausgeben_array[$i]) == intval($id))
{
if($Bild=="")
{
$Bild="0";
if (!file_exists("http://www.tutorials.de/forum/images/" . $Bild))
{
$Bild="1";
}
}
//We got all record information out!
//Example of usage:
if ($id%2==0)
{
print("<tr>");
}
else
{
print("<tr bgcolor=#CCCCCC>");
}
//Spalten
print("<td width=-6 height=44 valign=top><font face=Arial size=2> $id.<br><input type=checkbox value=$id name=ausgeben[] checked> </font></td>");
print("<td width=108 height=44>");
if ($Bild=="1")
{
print(" <b><font face=Arial size=2>Kein Bild vorhanden</font></b> ");
}
else
{
print("<img src=images/$Bild width=150>");
}
print("</td>");
print("<td width=200 height=44 valign=top><b><font face=Arial size=2>$Bezeichnung1</b>
<br>
Best.Nr.:
<br>
$Bezeichnung2
<br>
<br>
<b>Preis: $Preis EUR</b>
</font>
</td>");
if($id=="1")
{
$id="2";
}
else
{
$id=$id+1;
}
//}
}
}
}
fclose ($handle);
print("</tr></table>");
}
?>
Kommt ihr damit weiter?Geändert von D@nger (28.08.06 um 15:35 Uhr)
-
28.08.06 16:07 #5D@nger Tutorials.de Gastzugang
So, jetzt sollte es stimmen

PHP-Code:<?php
$sent = $_GET['sent'];
$ausgeben = $_GET['ausgeben'];//Inhalt der Checkboxen
if ($sent == 'yes')
{
$ausgeben_text = implode(', ',$ausgeben);
// $ausgeben_array=explode(', ',$ausgeben_text);
echo $ausgeben_text. "<br>";
// in $ausgeben_text steht 98, 99
$file = "CL_Artikelstamm.txt";
$lines = file($file);
$numlines = count($lines);
print('<table border="1" cellpadding="10" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" height="128">');
$row = 1;
$handle = fopen ("CL_Artikelstamm.txt","r");
$id="1";
$i=0;
$d=0;
//while($id < $numlines && $id < 10) {
$ausgeben_array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100);
while (($data = fgetcsv ($handle, 1000, ";") AND $id < $numlines AND $id < array_pop($ausgeben_array)+1) !== FALSE)
{
$num = count ($data);
$row++;
$Bezeichnung1 = $data[2];
$Bezeichnung2 = $data[3];
$Preis = $data[7];
$Bild = $data[8];
//Get all field information out of the table
//Parse errors from the information (U
$Bezeichnung1 = str_replace("/n", "<br>", $Bezeichnung1);
$Bezeichnung2 = str_replace("/n", "<br>", $Bezeichnung2);
// $Preis = number_format($Preis, 2, ",", "");
// if ($i != 0)
// {
// $d=$i+1;
// }
for ($i; $i < sizeof($ausgeben_array); $i++)
{
if (intval($ausgeben_array[$i]) == intval($id))
{
if($Bild=="")
{
$Bild="0";
if (!file_exists("images/" . $Bild))
{
$Bild="1";
}
}
if ($id%2==0)
{
print("<tr>");
}
else
{
print("<tr bgcolor=#CCCCCC>");
}
//Spalten
print("<td width=-6 height=44 valign=top><font face=Arial size=2> $id.<br><input type=checkbox value=$id name=ausgeben[] checked> </font></td>");
print("<td width=108 height=44>");
if ($Bild=="1")
{
print(" <b><font face=Arial size=2>Kein Bild vorhanden</font></b> ");
}
else
{
print("<img src=images/$Bild width=150>");
}
print("</td>");
print("<td width=200 height=44 valign=top><b><font face=Arial size=2>$Bezeichnung1</b>
<br>
Best.Nr.:
<br>
$Bezeichnung2
<br>
<br>
<b>Preis: $Preis EUR</b>
</font>
</td>");
if($id=="1")
{
$id="2";
}
else
{
$id=$id+1;
}
}
}
}
fclose ($handle);
print("</tr></table>");
}
?>Geändert von D@nger (28.08.06 um 16:15 Uhr)
Ähnliche Themen
-
Compiler-Warnung wenn Variable nicht gesetzt wird
Von XtremeCJ im Forum .NET Application und Service DesignAntworten: 3Letzter Beitrag: 26.07.09, 16:01 -
Überprüfung ob eine Variable gesetzt ist
Von mkoeni1 im Forum PHPAntworten: 2Letzter Beitrag: 18.12.07, 10:39 -
cookie wird nicht gesetzt
Von DarkManX im Forum PHPAntworten: 11Letzter Beitrag: 26.07.05, 03:20 -
Pruefen ob Variable gesetzt ist (=isset)
Von rainerdam im Forum .NET ArchivAntworten: 6Letzter Beitrag: 05.10.04, 11:32 -
chown wird nicht gesetzt :-/
Von Friesi im Forum PHPAntworten: 3Letzter Beitrag: 16.05.04, 17:50





Zitieren
Login






[PHP][Snippet] Array zu XML konvertieren