pragmaMx Support Forum

alles für Webmaster => PhP & mySQL => Thema gestartet von: alea am 30 September 2004, 18:22:22

Titel: Tabellenbefehl
Beitrag von: alea am 30 September 2004, 18:22:22
Hallo,

ich möchte Folgendes machen:

der Amazon-Block, der die Bilder der Bücher läd, soll drei Bücher gleichzeitig laden und zwar sollen diese nebeneinander erscheinen. Wenn ich den ursprünglichen Befehl verdopple, kommen die Bilder untereinander. Sollen sie nebeneinander stehen, muss ich sie wohl in Spalten setzten; doch wie geht eine Tabellenaufteilung in php?

Hat jemand einen Tipp?
Titel: Re: Tabellenbefehl
Beitrag von: NeMeSiSX2LC am 30 September 2004, 18:25:37
so müsste die aufteilung aussehen
<table>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
Titel: Re: Tabellenbefehl
Beitrag von: alea am 30 September 2004, 18:29:38
Also ich hab die Aufteilung so gemacht und es zeigt nur Fehler an:

 
Zitat<?php
#### Generated by Block Creator by Disipal Site (www.disipal.net) ###
if (eregi("block-Block_Creator.php",$PHP_SELF)) {
    Header("Location: index.php");
    die();
}
$content  =  "<body>";
$content  .= "<table width=\"100%\" height=\"152\" border=\"0\">";
$content  .= "  <tr>";
$content  .= "    <td width=\"33%\" height=\"51\"> </td>";
$content  .= "    <td width=\"33%\"><div align=\"center\"><strong>Bücherecke</strong></div></td>";
$content  .= "    <td width=\"33%\"> </td>";
$content  .= "  </tr>";
$content  .= "  <tr>";
$content  .= "    <td><div align=\"center\">

$modname = "Amazon_Random";
require_once("modules/Amazon/l_config.php");


global $prefix, $dbi;
#$result = mysql_query("select * from ".$prefix."_amazon_links");
$result = sql_query("select url, lid, title, description from $prefix"._amazon_links." order by rand() LIMIT 1", $dbi);
while(list($url, $lid, $title, $description) = sql_fetch_row($result, $dbi)) {
      $description = substr($description, 0, 300);
      $first = strrpos($description,". ");
      if ($first < 150) $first = strrpos($description," ");
      $description = substr($description, 0, $first+1);
      $content .= "<b>".$title."</b><br><br><center><a href=\"modules.php?op=modload&name=Amazon&file=index&l_op=viewlinkinfos&lid=$lid\"><img src=\"http://images-eu.amazon.com/images/P/".$url.".03.MZZZZZZZ.jpg\" border=\"0\"></a></center><br>".$description." <a href=\"modules.php?op=modload&name=Amazon&file=index&l_op=viewlinkinfos&lid=$lid\"><b>mehr...</b>\n";



}

</div></td>";  (weiter kommt dann die zweite Spalte mit dem gleichen Inhalt)


Was ist hier falsch?
Titel: Re: Tabellenbefehl
Beitrag von: NeMeSiSX2LC am 30 September 2004, 18:36:52
oh hehe is ja noch einfacher:-) Schau mal bei der DB abfrage steht hinten was von LIMIT 1 stell das mal auf 3 und dann noch ganz am schluss beim </b> ein  dahinter alles andere wieder weg was weiter unten steht.
Titel: Re: Tabellenbefehl
Beitrag von: alea am 30 September 2004, 18:41:36
also ganz am Ende so?

<b>mehr...</b>;



}


und das war´s?
Titel: Re: Tabellenbefehl
Beitrag von: alea am 30 September 2004, 19:38:02

nee, klappt leider nicht.

in jeder tabelle sollte diese funktion stehen:

 
Zitat$modname = "Amazon_Random";
require_once("modules/Amazon/l_config.php");


global $prefix, $dbi;
#$result = mysql_query("select * from ".$prefix."_amazon_links");
$result = sql_query("select url, lid, title, description from $prefix"._amazon_links." order by rand() LIMIT 1", $dbi);
while(list($url, $lid, $title, $description) = sql_fetch_row($result, $dbi)) {
$description = substr($description, 0, 300);
$first = strrpos($description,". ");
if ($first < 150) $first = strrpos($description," ");
$description = substr($description, 0, $first+1);
$content .= "<b>".$title."</b><br><br><center><a href=\"modules.php?op=modload&name=Amazon&file=index&l_op=viewlinkinfos&lid =$lid\"><img src=\"http://images-eu.amazon.com/images/P/".$url.".03.MZZZZZZZ.jpg\" border=\"0\"></a></center><br>".$description." <a href=\"modules.php?op=modload&name=Amazon&file=index&l_op=viewlinkinfos&lid =$lid\"><b>mehr...</b>\n";



}

und das drei mal nebeneinander...
Titel: Re: Tabellenbefehl
Beitrag von: NeMeSiSX2LC am 30 September 2004, 20:00:27
Das keine funktion!

Versuch mal das:
 
#### Generated by Block Creator by Disipal Site (www.disipal.net) ###
if (eregi("block-Block_Creator.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}
$content = "<body>";
$content .= "<table width=\"100%\" height=\"152\" border=\"0\">";
$content .= " <tr>";
$content .= " <td width=\"33%\" height=\"51\"> </td>";
$content .= " <td width=\"33%\"><div align=\"center\"><strong>Bücherecke</strong></div> ;</td>";
$content .= " <td width=\"33%\"> </td>";
$content .= " </tr>";
$content .= " <tr>";
$content .= " <td><div align=\"center\">

$modname = "Amazon_Random";
require_once("modules/Amazon/l_config.php");


global $prefix, $dbi;
#$result = mysql_query("select * from ".$prefix."_amazon_links");
$result = sql_query("select url, lid, title, description from $prefix"._amazon_links." order by rand() LIMIT 3", $dbi);
while(list($url, $lid, $title, $description) = sql_fetch_row($result, $dbi)) {
$description = substr($description, 0, 300);
$first = strrpos($description,". ");
if ($first < 150) $first = strrpos($description," ");
$description = substr($description, 0, $first+1);
$content .= "<b>".$title."</b><br><br><center><a href=\"modules.php?op=modload&name=Amazon&file=index&l_op=viewlinkinfos&lid =$lid\"><img src=\"http://images-eu.amazon.com/images/P/".$url.".03.MZZZZZZZ.jpg\" border=\"0\"></a></center><br>".$description." <a href=\"modules.php?op=modload&name=Amazon&file=index&l_op=viewlinkinfos&lid =$lid\"><b>mehr...</b>\n";



}

</div></td>"; (weiter kommt dann die zweite Spalte mit dem gleichen Inhalt)


Titel: Re: Tabellenbefehl
Beitrag von: alea am 30 September 2004, 22:39:40

Wenn ich es so mache, kommt fogender Fehler: Parse error: parse error in /block-b.php on line 17

in dieser zeile steht:

$modname = "Amazon_Random";
Titel: Re: Tabellenbefehl
Beitrag von: Andi am 01 Oktober 2004, 09:02:52
Moin :)

der parsefehler kommt von der zeile vor Zeile 17:
 $content .= " <td><div align=\"center\">
muss lauten:
 $content .= " <td><div align=\"center\">";

Massgebend bei parsefehlern ist nicht unbedingt die Zeilennummer sondern der zusätzlich ausgegebene Text.
Titel: Re: Tabellenbefehl
Beitrag von: seleck am 01 Oktober 2004, 11:22:44
Folgende Zeile stimmt auch nicht:

  $content .= "<b>".$title."</b><br><br><center><a href="modules.php?op=modload&name=Amazon&file=index&l_op=viewlinkinfos&lid =$lid\"><img src=\"http://images-eu.amazon.com/images/P/".$url.".03.MZZZZZZZ.jpg\" border=\"0\"></a></center><br>".$description." <a href=\"modules.php?op=modload&name=Amazon&file=index&l_op=viewlinkinfos&lid =$lid\"><b>mehr...</b>\n";
Titel: Re: Tabellenbefehl
Beitrag von: alea am 01 Oktober 2004, 11:29:27

Vielen dank, ich hab beide Zeilen korrigiert.

Das Problem ist jetzt nur, dass die Bücher im Block anstatt nebeneinander, hintereinander gezeigt werden.

ich hab folgenden code genommen:

 
Zitat<?php
#### Generated by Block Creator by Disipal Site (www.disipal.net) ###
if (eregi("block-Block_Creator.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}
$content = "<body>";
$content .= "<table width=\"100%\" height=\"152\" border=\"0\">";
$content .= " <tr>";
$content .= " <td width=\"33%\" height=\"51\"> </td>";
$content .= " <td width=\"33%\"><div align=\"center\"><strong>Bücherecke</strong></div> ;</td>";
$content .= " <td width=\"33%\"> </td>";
$content .= " </tr>";
$content .= " <tr>";
$content .= " <td><div align=\"center\">;

$modname = "Amazon_Random";
require_once("modules/Amazon/l_config.php");


global $prefix, $dbi;
#$result = mysql_query("select * from ".$prefix."_amazon_links");
$result = sql_query("select url, lid, title, description from $prefix"._amazon_links." order by rand() LIMIT 3", $dbi);
while(list($url, $lid, $title, $description) = sql_fetch_row($result, $dbi)) {
$description = substr($description, 0, 300);
$first = strrpos($description,". ");
if ($first < 150) $first = strrpos($description," ");
$description = substr($description, 0, $first+1);
$content .= "<b>".$title."</b><br><br><center><a href="modules.php?op=modload&name=Amazon&file=index&l_op=viewlinkinfos&lid =$lid\"><img src=\"http://images-eu.amazon.com/images/P/".$url.".03.MZZZZZZZ.jpg\" border=\"0\"></a></center><br>".$description." <a href=\"modules.php?op=modload&name=Amazon&file=index&l_op=viewlinkinfos&lid =$lid\"><b>mehr...</b>\n";



}

</div></td>";

?>


Der Block, der daraus entstand, bleibt nicht in der Mitte, sondern geht über die ganze rechte seite (die rechten Blöcke sind erst drunter zu sehen). Außerdem werden die Bücher in der ersten Spalte, dafür aber untereinander gezeigt.

Weiß jemand einen Rat?
Titel: Re: Tabellenbefehl
Beitrag von: jubilee am 01 Oktober 2004, 11:36:06
Hmmm .....
Versuch das mal :
 
Zitat<?php
#### Generated by Block Creator by Disipal Site (www.disipal.net) ###
if (eregi("block-Block_Creator.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}
$content = "";
$content .= "<table width=\"100%\" height=\"152\" border=\"0\">";
$content .= " <tr>";
$content .= " <td width=\"33%\" height=\"51\"> </td>";
$content .= " <td width=\"33%\"><div align=\"center\"><strong>Bücherecke</strong></div> ;</td>";
$content .= " <td width=\"33%\"> </td>";
$content .= " </tr>";
$content .= " <tr>";


$modname = "Amazon_Random";
require_once("modules/Amazon/l_config.php");


global $prefix, $dbi;
#$result = mysql_query("select * from ".$prefix."_amazon_links");
$result = sql_query("select url, lid, title, description from $prefix"._amazon_links." order by rand() LIMIT 3", $dbi);
while(list($url, $lid, $title, $description) = sql_fetch_row($result, $dbi)) {
$description = substr($description, 0, 300);
$first = strrpos($description,". ");
if ($first < 150) $first = strrpos($description," ");
$description = substr($description, 0, $first+1);
$content .= "<td><div align=\"center\"><b>".$title."</b><center><a href="modules.php?op=modload&name=Amazon&file=index&l_op=viewlinkinfos&lid =$lid\"><img src=\"http://images-eu.amazon.com/images/P/".$url.".03.MZZZZZZZ.jpg\" border=\"0\"></a></center>".$description." <a href=\"modules.php?op=modload&name=Amazon&file=index&l_op=viewlinkinfos&lid =$lid\"><b>mehr...</b></div></td>\n";



}

</tr></table>";

?>

 

MfG
jubilee


[Editiert am 1/10/2004 von jubilee]
Titel: Re: Tabellenbefehl
Beitrag von: seleck am 01 Oktober 2004, 11:42:23
ZitatFolgende Zeile stimmt auch nicht:

  $content .= "<b>".$title."</b><br><br><center><a href="modules.php?op=modload&name=Amazon&file=index&l_op=viewlinkinfos&lid =$lid\"><img src=\"http://images-eu.amazon.com/images/P/".$url.".03.MZZZZZZZ.jpg\" border=\"0\"></a></center><br>".$description." <a href=\"modules.php?op=modload&name=Amazon&file=index&l_op=viewlinkinfos&lid =$lid\"><b>mehr...</b>\n";

die musste eingentlich so lauten:

  $content .= "<b>".$title."</b><br><br><center><a href'modules.php?op=modload&name=Amazon&file=index&l_op=viewlinkinfos&lid =$lid'><img src='http://images-eu.amazon.com/images/P/".$url.".03.MZZZZZZZ.jpg\' border='0'></a></center><br>".$description." <a href='modules.php?op=modload&name=Amazon&file=index&l_op=viewlinkinfos&lid =$lid'><b>mehr...</b>\n";

$content .= "</div></td>";
Titel: Re: Tabellenbefehl
Beitrag von: alea am 01 Oktober 2004, 11:48:06

Hallo,

ja danke, ich habe dort ein \ eingefügt und soweit geht es jetzt, das einzige problem ist weiterhin, dass es fast die gesamte Seite in Anspruch nicht, anstatt in der Mitte zu bleiben.

Als ich %-Zahlen angeglichen habe, wurde zwar ganz rechts alles leer, doch weiterhin in diesem breiten block.
Titel: Re: Tabellenbefehl
Beitrag von: alea am 01 Oktober 2004, 17:50:54

ok, klappt jetzt.

Ich hab vergessen ans Ende </body> zu setzten  :redhead:
Titel: Re: Tabellenbefehl
Beitrag von: jubilee am 01 Oktober 2004, 21:15:17
Hallo !
 
ZitatIch hab vergessen ans Ende </body> zu setzten  
Ähhhh ... wofür denn das </body> ??
Brauchst im Block weder am Anfang ein <body> noch am Ende ein
</body> setzen. das wird schon von anderen Scripten erledigt .
MfG
jubilee
Titel: Re: Tabellenbefehl
Beitrag von: alea am 01 Oktober 2004, 22:13:55
Dann hab ich vergessen, die Tabelle zu schließen.

Jedenfalls ging der Block über di gesamte Länge; nachdem ich das hinzugefügt habe, wurde es den anderen Blöcken angepasst....wieso auch immer  :o

Nochmals danke für all die Anregungen und Hilfestellungen :)