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.

Nummerierung der zeilen

Empfohlene Antworten

moin moin

ich hab mir mal nen kleinen script gebastelt, aber eins bekomme ich nicht hin:

ich will beim folgenden script eine nummerierung vor die zeilen haben also sprich

1. .......

2. .......

3. .......

usw.

hat einer ne idee wie ich das am besten mache?

<?php

include("db/daten.inc.php");

$sql = "SELECT * FROM test ORDER BY 1";

$sql = mysql_query($sql);

echo "<table width=\"90%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">";

echo "<tr><td width=\"45%\"><b><font size=\"2\">test</font></b></td><td width=\"45%\"><b><font size=\"2\">test</font></b></td></tr>";

while ($daten = mysql_fetch_array($sql))

{

$1 = $daten["1"];

$2 = $daten["2"];

echo "<tr><td width=\"45%\"><font size=\"2\">".$1."</font></td><td width=\"45%\"><font size=\"2\">".$2."</font></td</tr>" ;

}

echo "</table>";

?>

Also ich würd's etwa so machen:


<?php
include("db/daten.inc.php");
$sql = "SELECT * FROM test ORDER BY 1";
$sql = mysql_query($sql);
?>
<table width="90%" border="1" cellspacing="0" cellpadding="0" align="center">
<tr><td width="45%"><b><font size="2">test</font></b></td><td width="45%"><b><font size="2">test</font></b></td></tr>
<?php
$i = 0;
while ($daten = mysql_fetch_array($sql)):

$1 = $daten["1"];
$2 = $daten["2"];
$i++;
?>
<tr><td width="45%"><font size="2"><?echo "$i. $1"; ?></font></td><td width="45%"><font size="2">"><?echo $2; ?></font></td</tr>
<?php endwhile ?>
</table>
[/PHP]

Die Variable $i wird dabei immer weiter hochgezählt und kann so als Zeilennummer benutzt werden. Ich kann den Code aber momentan nicht ausprobieren - könnte also sein, daß vielleicht noch ein Fehler drin ist...

Ich hab deinen Quellcode außerdem etwas (mMn) praktischer und lesbarer gemacht - man muß nämlich nicht jeden HTML-Code mit echo ausgeben...

Ansonsten würd ich dir außerdem noch raten, das Font-Tag möglichst nicht zu benutzen. AFAIK ist das nämlich mittlerweile aus dem HTML-Standard rausgeschmissen worden und könnte von neueren Browsern bald nicht mehr unterstützt werden... - Nimm lieber StyleSheets - die sind auch besser anzupassen!

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.