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.

Select Count (MySQL & PHP)

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

wir haben eine MySQL - Datenbank in der sich eine Tabelle befindet.

Ich möchte, daß er die Anzahl der Datensätze wiedergibt als Zahl ausgibt.

Mein Code sieht im Moment so aus... (der aber leider nicht geht)... warum ?

<html>

<head>

<title></title>

<link rel="stylesheet" href="../../liste.css" type="text/css">

</head>

<body bgcolor="#FFFFFF" link="#990000" vlink="#990000" alink="#990000">

<?PHP

$Host = "xxxxxxxxxx";

$User = "xxxxxxxxxx";

$Passwort = "xxxxxxxxxx";

$DBName = "xxxxxxxxxx";

$TableName = "ZahnarztListe";

$Suche = $String[suche];

$Prozent = "%";

$Temp = $Suche . $Prozent;

$Link = mysql_connect ($Host, $User, $Passwort);

$Query = "SELECT COUNT(*) FROM $TableName";

$Result = mysql_db_query ($DBName, $Query, $Link);

$Row = mysql_fetch_array ($Result);

print ("<font face=Verdana size=2><font color=ff0000>$Row</font></font>\n");

mysql_close ($Link);

?>

</body>

</html>

Warum gibt er mir nicht als Zahl die Anzahl der Tabellen wieder ?

Danke schonmal.

Sven

Originally posted by thesecretboy

Warum gibt er mir nicht als Zahl die Anzahl der Tabellen wieder ?

Weil du ihm nicht gesagt hast wo er die speichern soll ;)

In der Abfrage mußt du noch einen Feldnamen definieren:

$Query = "SELECT COUNT(*) AS Anzahl FROM $TableName";

Beim Auslesen ist $Row ein Array. Du mußt es dann auch so Ansprechen:

print ("<font face=Verdana size=2><font color=ff0000>$Row[Anzahl]</font></font>\n");

Oh man... hmm...

jedenfalls funktionierts. Vielen Dank für die schnelle Hilfe.

Voll der Blindgänger (nicht Du) ;)

Geht auch mit nem einfachen

SELECT COUNT(*) FROM table

Dann kommste über $row[0] an den Wert.

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.