|
|
Latest News |
Latest Threads |
|
 |
55.471 Posts & 4.945 Themen in 78 Foren |
|
|
|
 |
Forensuche |
|
Suchbegriff |
Benutzerauswahl |
Ergebnisse anzeigen |
 |
 |
newsboxes - zwei in einer box 5 Beiträge in diesem Thema |
|
|
 |
|
|
 |
|
 |
06.02.2008 - 16:34 Uhr |
|
|
|
tach...
ich möchte gerne 2 news in einer box anzeigen lassen. versuche es hiermit:
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 | | PHP-Quelltext $abcut_text = "400"; # Maximale Anzahl der Zeichen des Artikel Vorschau Textes - Standard: 90
$abcut_title = "100"; # Maximale Anzahl der Zeichen des Artikel Vorschau Titles - Standard: 25
$aboxkatid1 = "15"; # Kategorie ID fuer artikel
$getaboxinfo1 = $DB->query("SELECT
".$db_tab['content'].".content_id,
".$db_tab['content'].".content_title,
".$db_tab['content'].".content_text,
".$db_tab['content'].".content_time FROM
".$db_tab['content']." LEFT JOIN
".$db_tab['contentcat']." ON
".$db_tab['contentcat'].".contentcat_id=".$db_tab['content'].".content_cat WHERE
".$db_tab['content'].".content_option='1' AND
".$db_tab['content'].".content_status='1' AND
".$db_tab['contentcat'].".contentcat_id='".$aboxkatid1."' AND
".$db_tab['content'].".content_time<'".$time_now."' AND
(".$db_tab['content'].".content_expire>'".$time_now."' OR ".$db_tab['content'].".content_expire='0') AND
".sqlrights($db_tab['contentcat'].'.contentcat_rights')." ORDER by
".$db_tab['content'].".content_time DESC LIMIT 2");
$aboxinfo1 = $DB->fetch_array($getaboxinfo1);
if($aboxinfo1!='') {
$abox1_time = formattime($aboxinfo1['content_time']);
$abox1_id = $aboxinfo1['content_id'];
$abox1_text =substr(strip_tags($PARSE->parse($aboxinfo1['content_text'],1,1,1,1)),0,$abcut_text);
$abox1_title = cutstring($aboxinfo1['content_title'],$abcut_title);
}
else
{
unset($abox1_title);
unset($abox1_time);
unset($abox1_id);
unset($abox1_text);
}
$artikel.= "<b>$abox1_title</b> <small>$abox1_time</small><br>$abox1_text...<br><small><a href='include.php?path=content/articles.php&contentid=$abox1_id' target='_self'>vollständig lesen</a></small><br><br>";
| |  |
wird aber nur ein artikel angezeigt, was mache ich falsch?!
|
|
|
|
|
|
|
 |
|
 |
06.02.2008 - 17:47 Uhr |
|
|
|
Du must das in einer while-Schleife machen.
Also so:
Hier klicken zum aufklappen 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 | | PHP-Quelltext $abcut_text = "400"; # Maximale Anzahl der Zeichen des Artikel Vorschau Textes - Standard: 90
$abcut_title = "100"; # Maximale Anzahl der Zeichen des Artikel Vorschau Titles - Standard: 25
$aboxkatid1 = "15"; # Kategorie ID fuer artikel
$getaboxinfo1 = $DB->query("SELECT
".$db_tab['content'].".content_id,
".$db_tab['content'].".content_title,
".$db_tab['content'].".content_text,
".$db_tab['content'].".content_time FROM
".$db_tab['content']." LEFT JOIN
".$db_tab['contentcat']." ON
".$db_tab['contentcat'].".contentcat_id=".$db_tab['content'].".content_cat WHERE
".$db_tab['content'].".content_option='1' AND
".$db_tab['content'].".content_status='1' AND
".$db_tab['contentcat'].".contentcat_id='".$aboxkatid1."' AND
".$db_tab['content'].".content_time<'".$time_now."' AND
(".$db_tab['content'].".content_expire>'".$time_now."' OR ".$db_tab['content'].".content_expire='0') AND
".sqlrights($db_tab['contentcat'].'.contentcat_rights')." ORDER by
".$db_tab['content'].".content_time DESC LIMIT 2");
while ($aboxinfo1=$DB->fetch_array($getaboxinfo1)) {
$abox1_time = formattime($aboxinfo1['content_time']);
$abox1_id = $aboxinfo1['content_id'];
$abox1_text =substr(strip_tags($PARSE->parse($aboxinfo1['content_text'],1,1,1,1)),0,$abcut_text);
$abox1_title = cutstring($aboxinfo1['content_title'],$abcut_title);
$artikel.= "<b>$abox1_title</b> <small>$abox1_time</small><br>$abox1_text...<br><small><a href='include.php?path=content/articles.php&contentid=$abox1_id' target='_self'>vollständig lesen</a></small><br><br>";
unset($abox1_title);
unset($abox1_time);
unset($abox1_id);
unset($abox1_text);
} | |  |
|
|
|
|
|
|
|
 |
|
 |
06.02.2008 - 18:41 Uhr |
|
|
|
danke funkt perfekt! ist while-schleife nicht eig. die bedinungung, die audrückt, dass etwas solange ausgeführt wird, wie es erfüllt ist und somit im gegensatz zu if keine endlosschleifen entsethen können?! - sry laber hier nur schrott - macht sinn 
|
|
|
|
|
|
|
 |
|
 |
06.02.2008 - 18:58 Uhr |
|
|
|
Eine while-Schleife ist nicht umbedingt eine Bedingung. Es ist eine Schleife, die auch unendlich sein kann, die durch die Einstellung (also die eigentliche Bedingung), arbeitet.
In diesen Fall sucht der Server die Daten aus der Datenbank raus, die durch den WHERE ausgefiltert werden.
Wenn diese "Bedingung" vorhanden / erfüllt wird, werden die Daten ausgegeben.
Bei einer if-Bedingung wird ja nur "Wenn 1 = 1 ist, kommt XX).
Da spielt es keine Rolle, ob dies einmal oder 1000 mal vorhanden ist.
Du kannst aber auch den Befehl foreach und Konsorten benutzen. Funktioniert wie ich das jetzt kenne, wie die while-Schleife.
|
|
|
|
|
|
|
 |
|
 |
06.02.2008 - 20:32 Uhr |
|
|
|
danke mal wieder für die ausführliche belehrung 
|
|
|
|
|
|
|
 |
Ähnliche Themen |
|
|
|
|
|
|
|
|