\n aus beitrag entfernen?
Verfasst: 02.12.2007 04:57
ich würde gerne eine Javascript funktion bei einem Onlick auf einem Bild verwenden, welche von Datenbank Einträgen in PHP "erstellt" wird, dafür müssen aber die neuen Zeilen für Javascript entfernt werden, sonst funktioniert es nicht richtig!
Es sieht wie folgt aus (mit Versuch zur Lösung):
Danke für die Hilfe!
Es sieht wie folgt aus (mit Versuch zur Lösung):
Code: Alles auswählen
<?php
function no_nl($text){
$return = preg_replace('/\\n/', '', $text);
return $return;
}
$output = "<script type="text/javascript">
function openPic(pid, text) {
document.getElementById('galleryitem').src=''+pid;
if (text=='') {
text = 'Keine Bildbeschreibung vorhanden';
}
document.getElementById('galleryitemtext').firstChild.nodeValue = text;
return true;
}
</script>";
[...]
while ($row = mysql_fetch_assoc($result1)) {
$Eintrag = utf8_decode(nl2br($row['Eintrag']));
$groesse = @GetImageSize("bilder/" . $row['Bild']);
$output .= "<h3>$row[1]</h3>\n
/*<p><img src='bilder/".$row['Bild']."' ".$groesse[3]." alt='".utf8_decode($row['Headline'])."'></p>
<div>$Eintrag</div>" . "<p>eingetragen von <b>".utf8_decode($row['Name'])."</b> am <strong>" . datemaker2($row['Datum']) . "</strong>";*/
$picshow .= "<img onclick=\"openPic('bilder/$row[Bild]', '".utf8_decode($row['Headline'])."');document.getElementById('galleryitemeintrag').innerHTML = '".no_nl($Eintrag)."';\" style=\"border: 1px solid rgb(0, 0, 0); cursor: pointer;\" src=\"http://www.phpbb.de/images/nav/phpbb_logo.gif\" alt=\"".utf8_decode($row['Headline'])."\">";
} // while Ende
$picshow .= "";
$output .= <<<PICSHOW
<div style="margin: 5px;">Zur Vollansicht die Vorschaubilder anklicken.</div>
<div style="overflow: auto; width: 100%; height: 134px; text-align: center;">
<nobr style="height:800px">
{$picshow}
</nobr>
</div>
<div style="text-align: center; margin-top: 10px;">
<img src="BILD" alt="" style="margin: 5px 15px 15px;" id="galleryitem">
<div style="border: 1px solid rgb(170, 170, 170); padding: 5px; background: rgb(242, 242, 242) none repeat scroll 0%; text-align: center; margin-bottom: 7px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-weight: bold" id="galleryitemtext">
!!TEXT!!</div>
<div style="border: 1px solid rgb(170, 170, 170); padding: 5px; background: rgb(242, 242, 242) none repeat scroll 0%; text-align: center; margin-bottom: 7px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-weight: bold" id="galleryitemeintrag">
!!EINTRAG!!</div>
PICSHOW;
?>
Danke für die Hilfe!