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.

[PHP] Liste aus Datenbank als Link ausgeben lassen

Empfohlene Antworten

Veröffentlicht

So, sorry für den krummen Titel, wusste nicht wie ichs sonst beschreiben sollte.

Also folgendes, ich habe eine Tabelle in der Datenbank in der Texte gespeichert werden. Die Datenbank enthält die Felder doc_id (auto increment, tiny_int), titel (text) und doc (text).

Nun möchte ich mir eine Liste der Einträge ausgeben lassen und die einzelnen Einträge dieser Liste sollen als links auf eine Datei verweisen die später erstellt wird und dann je nach dem was man anklick das Feld doc zur dazu gehörigen doc_id ausgibt.

Ist ja Theoretisch ganz einfach. SQL-Anweisung schreiben, die die Felder titel und doc_id ausließt, das ganze fetchen und dan mit hilfe eienr Tabelle das ganze so ausgeben, dass man am Ende eine Liste mit den Titeln hat die dann als Links dienen.

Also zu den Dokument mit dem Titel "Hallo" gibt es den Link "showdoc.php$id=1"

Das Skript sieht bei mir so aus:

$erg=mysql_query("SELECT titel, doc_id FROM doc ORDER BY doc_id");
echo "<table>";
while ($line = mysql_fetch_array($erg, MYSQL_ASSOC)) {
echo "<tr>";

foreach ($line as $col_value) {
echo "<td><a href=\"showdoc.php?id=".$col_value['doc_id']."\">".$col_value['titel']."</a></td>";
}
echo "</tr>";[/PHP]

Lustigerweise gibt er mir nicht so eine Tabelle aus:

Hallo

____

allo

sondern sowas:

a | 1

__|__

|

H | 2

also statt einer Spalte mit Titel (+ link dahinter) gibt es 2 Spalten (1. Spalte = erster Buchstabe des Titels, 2. Spalte = id beide mit links).

Hat irgendwer ne Idee wo es hapert?

(hoffentlich steigt jemand durch meine krumme Erklärung)

MFG

Uri

$erg=mysql_query("SELECT titel, doc_id FROM doc ORDER BY doc_id");
echo "<table>";
while ($line = mysql_fetch_array($erg, MYSQL_ASSOC)) {
echo "<tr>";

echo "<td><a href=\"showdoc.php?id=".$line['doc_id']."\">".$line['titel']."</a></td>";
echo "</tr>";
}[/PHP]

Versuch es mal so. [ungetestet]

  • Autor
$erg=mysql_query("SELECT titel, doc_id FROM doc ORDER BY doc_id");
echo "<table>";
while ($line = mysql_fetch_array($erg, MYSQL_ASSOC)) {
echo "<tr>";

echo "<td><a href=\"showdoc.php?id=".$line['doc_id']."\">".$line['titel']."</a></td>";
echo "</tr>";
}[/PHP]

Versuch es mal so. [ungetestet]

Alter Verwalter, es funzt. Man und ich quäl mich hier rum, wo ich einfach nur mal die foreach Schleife hätte wegkommentieren müssen >__>"

Besten dank, Meister ^^

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.