Warnung: file_put_contents(/home/www/web1/html/php_dev/test.txt) [function.file-put-contents]: failed to open stream: Permission denied in /home/www/web1/html/php_dev/sys/lib.activity.php (Zeile 58)
Daten ausgeben [Archiv] - PHP-Scripte PHP-Tutorials PHP-Jobs und vieles mehr
brauche Webseite ideal für Vereine und Firmen
- Ad -
php-resource




Archiv verlassen und diese Seite im Standarddesign anzeigen :
Daten ausgeben


 
Schoppy
07-08-2002, 12:29 
 
Hallo zusammen...

ich habe in einem Script folgenden Quelltext:


<?php
// Daten auslesen
$r1 = MySQL_QUERY("SELECT * FROM $cat ORDER BY id ASC");



// Ausgabe
while ($d1= mysql_fetch_array($r1)) {

$gesamtlinks = mysql_query("SELECT count(*) as gesamtlinks from $links WHERE bereich='$d1[id]'");
$gesamtlinks = mysql_fetch_array($gesamtlinks);

echo "<table border=0 cellspacing=1 cellpadding=0 bgcolor=#000000>";
echo "<tr><td>";

echo "<table border=0 cellpadding=2 cellspacing=0 class=content width=300>";
echo "<tr><td bgcolor=#999999 class=content><img src=../../images/shared/wl_klein.gif> <a href='detail.php?cat=".$d1[id]."' class='Link'>".$d1[titel]."</a> (".$gesamtlinks[0]." Links - ".$d1[hits]." Hits)</td></tr>";
echo "</table>";
echo "</td></td></table><br>";
}
?>


Nun möchte ich allerdings die Tabellen nicht untereinander ausgeben, sondern jeweils 2 in einer Zeile und dann die nächsten beiden. Wie mache ich das ???

Danke für eure Hilfe !!!

 
Radium2k
07-08-2002, 14:48 
 
probier das mal :



<?php
// Daten auslesen
$r1 = MySQL_QUERY("SELECT * FROM cat ORDER BY id ASC");



// Ausgabe
$tr = "0";
while ($d1= mysql_fetch_array($r1)) {
++$tr;
$gesamtlinks = mysql_query("SELECT count(*) as gesamtlinks from $links WHERE bereich='$d1[id]'");
$gesamtlinks = mysql_fetch_array($gesamtlinks);

echo "<table border=0 cellpadding=2 cellspacing=0 class=content width=300>";
if ($tr = "2") { echo "<tr>"; }
echo "<td bgcolor=#999999 class=content><img src=../../images/shared/wl_klein.gif> <a href='detail.php?cat=".$d1[id]."' class='Link'>".$d1[titel]."</a> (".$gesamtlinks[0]." Links - ".$d1[hits]." Hits)</td>";
if ($tr = "2") { echo "</tr>"; $tr = "0"; }
echo "</table>";
}
?>

 
Schoppy
07-08-2002, 16:32 
 
Gute Idee...aber klappt bei mir leider nicht :-(

 
hand
07-08-2002, 19:18 
 
<?php
// Daten auslesen
$r1 = MySQL_QUERY("SELECT * FROM cat ORDER BY id ASC");



// Ausgabe
$tr = 0;
while ($d1= mysql_fetch_array($r1)) {
$tr++;
$gesamtlinks = mysql_query("SELECT count(*) as gesamtlinks from $links WHERE bereich='$d1[id]'");
$gesamtlinks = mysql_fetch_array($gesamtlinks);

echo "<table border=0 cellpadding=2 cellspacing=0 class=content width=300>";
if ($tr == 2) { echo "<tr>"; }
echo "<td bgcolor=#999999 class=content><img src=../../images/shared/wl_klein.gif> <a href='detail.php?cat=".$d1[id]."' class='Link'>".$d1[titel]."</a> (".$gesamtlinks[0]." Links - ".$d1[hits]." Hits)</td>";
if ($tr == 2) { echo "</tr>"; $tr = 0; }
echo "</table>";
}
?>

 
Schoppy
07-08-2002, 19:26 
 
Hmm...danke...habe ich jetzt auch probiert und bekomme folgende Meldung:

Warning: Supplied argument is not a valid MySQL result resource in C:\Xitami\webpages\XXX\XXX\links.php on line 120

Und nun ?

 
hand
07-08-2002, 19:37 
 
Wo ist Zeile 120?
An den Selects udgl hat sich nix geändert.
Ich habe lediglich am Vorschlag von Radium2k eine kleine Korrektur vorgenommen, anstatt if ($tr = "2") -> if ($tr == 2), damit die Tags <tr> und </tr> ausgegeben werden. Diese Ifs haben aber sicher keinen Einfluß auf den Selectstring

 
Schoppy
07-08-2002, 19:39 
 
Sorry...

das ist Zeile 120:

$tr = 0;

 
hand
07-08-2002, 19:50 
 
Diese Zeile hat aber mit einer Fehlermeldung wie "Warning: Supplied argument is not a valid MySQL result resource in C:\Xitami\webpages\XXX\XXX\links.php on line 120" nix zu tun!

Schau bitte nochmal genau

 
Schoppy
07-08-2002, 19:56 
 
So...

den Fehler habe ich nun alleine gefunden...hatte im SQL-String den falschen Tabellenname :-(

Allerdings gibt das Script die Daten immernoch untereinander aus und nicht wie gewünscht 2 nebeneinander und darunter dann die nächsten 2.

Ich verzweifle noch...

 
hand
07-08-2002, 20:00 
 
Post mal was Du jetzt hast

 
Schoppy
07-08-2002, 20:15 
 
Naja...eigentlich genau das was du geschrieben hast:


<?php
// Daten auslesen
$r1 = MySQL_QUERY("SELECT * FROM $cat ORDER BY id ASC");



// Ausgabe
$tr = 0;
while ($d1= mysql_fetch_array($r1)) {
$tr++;
$gesamtlinks = mysql_query("SELECT count(*) as gesamtlinks from $links WHERE bereich='$d1[id]'");
$gesamtlinks = mysql_fetch_array($gesamtlinks);

echo "<table border=0 cellpadding=2 cellspacing=0 class=content width=300>";
if ($tr == 2) { echo "<tr>"; }
echo "<td bgcolor=#999999 class=content><img src=../../images/shared/wl_klein.gif> <a href='detail.php?cat=".$d1[id]."' class='Link'>".$d1[titel]."</a> (".$gesamtlinks[0]." Links - ".$d1[hits]." Hits)</td>";
if ($tr == 2) { echo "</tr>"; $tr = 0; }
echo "</table>";
}
?>

 
hand
07-08-2002, 20:22 
 
Nun denn, ich hoffe jetzt klappt es ....

<?php
// Daten auslesen
$r1 = MySQL_QUERY("SELECT * FROM cat ORDER BY id ASC");

// Ausgabe
$tr = 0;
echo "<table border=0>";
while ($d1= mysql_fetch_array($r1)) {
$gesamtlinks = mysql_query("SELECT count(*) as gesamtlinks from $links WHERE bereich='$d1[id]'");
$gesamtlinks = mysql_fetch_array($gesamtlinks);

$tr++;
if ($tr == 1) {
echo "<tr>";
}
echo "<td>";

echo "<table border=0 cellpadding=2 cellspacing=0 class=content width=300>";
echo "<td bgcolor=#999999 class=content><img src=../../images/shared/wl_klein.gif> <a href='detail.php?cat=".$d1[id]."' class='Link'>".$d1[titel]."</a> (".$gesamtlinks[0]." Links - ".$d1[hits]." Hits)</td>";
echo "</table>";

echo "</td>";
if ($tr == 2) {
echo "</tr>";
$tr = 0;
}
}

if ($tr == 1) {
echo "</tr>";
}
echo "</table>";
?>

 
Schoppy
07-08-2002, 20:27 
 
Super....danke...das Ergebnis gefällt mir richtig gut...:)

- -

Alle Zeitangaben in WEZ +2. Es ist jetzt 13:29 Uhr.