Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Datenbank Auslesung beschränken

Empfohlene Antworten

Veröffentlicht

Hallo,

ich habe folgendes Problem:

ein PHP-Skript liest aus einer MySQL-Tabelle Zeile für Zeile Text. Nun will ich es aber dazu bringen, dass es nur den Inhalt der letzten fünf Zeilen ausgibt und die zuerst eingelesenen vernachlässigt.

Wie macht man das?

Bin mir nicht so ganz sicher, aber probier mal das:

mysql(datenbank,"select * from tabelle order by eintrags_id desc limit 5");

Hoffe, es funktioniert.

hi lunatic82,

nimm dazu eine aggregatfunktion wie last() bzw. bottom().

gruss

<FONT COLOR="#a62a2a" SIZE="1">[ 30. August 2001 14:15: Beitrag 1 mal editiert, zuletzt von hades ]</font>

Hallo,

<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Zitat:</font><HR> nimm dazu eine aggregatfunktion wie last() bzw. bottom().

<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Zitat:</font><HR>Original erstellt von Jaraz:

<STRONG>Hallo,

Habe ich noch nie was von gehört.

Du kannst aber bei jedem Datensatz einen timestamp mit abspeichern.

Und die Ausgabe dann nach dem timestamp sortiert ausgeben.

Gruß Jaraz</STRONG>

Danke für eure Antworten, aber ich hab es dann auf eine weniger elegante Art gelöst. Und zwar wird jetzt die gesamte Datenbank ausgelesen und jede Zeile in einem Array gespeichert. Das hat auch den Vorteil, dass man gezielt auf einzelne Elemente zugreifen kann. Das ganze sieht jetzt so aus (für die, die es interessiert :-))

echo "<h4>Die lezten fünf Artikel:</h4>\n";

$query = mysql_query($sql_news);

$i = 0;

while ($zeilea = mysql_fetch_row($query))

{

$array[$i] = $zeilea;

$i++;

}

for ($a = (sizeof($array) - 1); $a >= (sizeof($array)- 5) ; $a--)

{

echo "<div align=left><li><b><a class=newsbig href=\"show_news.php?news_id=" . $array[$a][0] ."\">  " . $array[$a][2] . "</a></b> <font size=\"-1\"> | Datum: " .$array[$a][1] . "</font></li></div>\n";

}

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.