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.

mySQL und PHP

Empfohlene Antworten

Veröffentlicht

Hi Leute,

ich habe folgendes Problem mit PHP und mySQL:


$result = mysql_query("select K_Name from kat where U_Kat=4");

  while ($row = mysql_fetch_array($result, MYSQL_NUM))

  {

    $i=1;

    foreach($row as $attribute)

    {

      echo "<li class=\"menuepunkt\"><center>

               <input type=\"submit\" name=\"kat\" value=\"".$attribute."\" 

                id=\"navi\" class=\"".[B][COLOR="Red"]$i[/COLOR][/B]."_link\"/></center></li>"; 

      $i++;

    }

  }

Ich möchte, dass in der Schleife die Klasse vom input immer um 1 hochgezählt wird, sodass das nächste ausgelesene Attribut aus der Datenbank die nächste Klasse bekommt.

Mit dem jetzigen Quellcode wird '$i' nicht hochgezählt.

Alle Attribute haben somit die gleiche Klasse.

Weißt jemand wie ich so etwas realisieren kann?

Danke schonmal im Vorraus.

MfG

Also ich würds so machen:


$result = mysql_query("select K_Name from kat where U_Kat=4");
$i=1;
while ($row = mysql_fetch_assoc($result))
{
echo "<li class=\"menuepunkt\"><center>
<input type=\"submit\" name=\"kat\" value=\"".$row['K_Name']."\"
id=\"navi\" class=\"".$i."_link\"/></center></li>";
$i++;
}

[/php]

das $i = 1; auf jeden Fall nicht in das while ;-)

super, danke hat geklappt ;)

Kein Problem.

das $i=1; war übrigens der Fehler. In jedem Durchgang hast du i immer wieder auf 1 gesetzt.

und geändert hab ich den Code mit ohen foreach nur weils so einfacher ist :-D

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.