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] Welche Ausgabe für SQL und Sortierung

Empfohlene Antworten

Veröffentlicht

Hi

Ich hab da mal ne Frage zur Ausgabe von MySQL Datensätzen. Ich hab jetzt schon einiges in PHP ausprobiert und verwende bisher zur Ausgabe von Datensätzen:

for ($i=0; $i<$anzahldatensaetze; $i++)

{

$nummer=mysql_result($sqlabfrage, $i, "nummer");

echo $nummer

}

Mir hat jetzt ein Bekannter gesagt, dass diese Ausgabe viel zu langsam ist und ich lieber mysql_fetch_array verwenden soll.

Ist das fetch_array wirklich schneller und besser? Wie würde denn mein Beispiel mit fetch_array aussehen?

Und weiss vielleicht einer wie das hier auf der Fachinformatiker Seite gaaaanz unten mit den Page generated in blabla seconds (47.63% PHP - 52.37% MySQL) funktioniert?

Dankö!

Noxy

das schnellste ist nach eigener Beobachtung:


$sqlresult = mysql_query("SELECT spalte1,spalte2,spalte3 FROM tabelle");
$anzahl_datensaetze = mysql_num_rows($sqlresult);
while ($row = mysql_fetch_row($sqlresult) {
echo "Spalte 1: $row[0], Spalte2: $row[1], Spalte3: $row[2]";
}
echo "Anzahl Gesamt Datensaetze: $anzahl_datensaetze";
[/PHP]

mittlerweile ist aber auch die funktion mysql_fetch_assoc() genauso schnell, und hat den Vorteil das man Spaltennamen verwenden kann:

[PHP]
$sqlresult = mysql_query("SELECT spalte1,spalte2 as bubu,spalte3 FROM tabelle");
$anzahl_datensaetze = mysql_num_rows($sqlresult);
while ($row = mysql_fetch_assoc($sqlresult) {
echo "Spalte 1: ".$row["spalte1"].", Spalte2: ".$row["bubu"].", Spalte3: ".$row["spalte3"];
}
echo "Anzahl Gesamt Datensaetze: $anzahl_datensaetze";

meine Meinung

gruß gurkenpapst

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.