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-Daten in Select-Drop-Down-Feld einbinden

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

ich habe nicht ganz so viel Ahnung bezogen auf PHP und möchte gerne ein Select-Dropdown-Feld in einer HTML-Seite via PHP mit Daten aus einer MYSQL-Datenbank füllen.

Wenn ich nur die PHP-Anweisung einzeln in eine Seite packe, dann funktioniert diese aber wenn ich sie in dieses Select-Feld einbinde, dann wird in dem Feld die Zeichenfolge ".$arr['filiale']." angezeigt

Warum?!?

Danke für Eure Hilfe!

vplus

Hier der passende Quellcode...


<?php

//Datenbankverbindung

$server="xxx.xx.xxx.xxx:xxx";

$user="test";

$pass="pw";

$db="test_db";

$connection=mysql_connect($server,$user,$pass);

$test= mysql_select_db($db, $connection);

?>

<html>

<head>

<title>Seitenname</title>

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

</head>

<body bgcolor="#FFFFFF" scroll="auto">


<form name="Testform" action="test.php" method="POST">

<br>

<fieldset>

<legend><b>Bitte machen Sie Angaben zum Auftrag</b></legend>

<table>

<tr>

<td>Filiale</td> 

<td>Auftrags-Nr.</td>

<td>Auftrags-Position</td>

</tr>

<tr>

<td> 

<select name="FILIALE" size="1" tabindex ="1"> 

<? 

$sql = "select id, filiale from tab_filialen order by filiale"; 

$query = mysql_query($sql); 

print("<option selected value=' '> </option>"); 

while ($arr = mysql_fetch_array($query)) { 

print("<option value = '". $arr['id']."'>".$arr['filiale']."</option>");

} 

?>

</select>

</td>

<td><input class="iprequired" name="AUFTRAG" type="text" size="30"/></td>

<td><input class="iprequired" name="POSITION" type="text" size="30"/></td>

</tr>

</table>

</fieldset>

</body>

</html>

Hast du schonmal probiert auch da mit einer ID zu arbeiten? Die ID sollte ja für die Spalte stehen. Oder du probierst mal anstatt mysql_fetch_array die Methode mysql_fetch_assoc oder mysql_fetch_rows...

Habs nimmer so ganz im Kopf, wie und welche Funktion das war...

Kann aber evtl nochmal nachschauen.

Vielleicht hast du es aber auch schon gelöst ;)

MfG


$moep = mysql_query("SELECT * FROM `table`");
$num = mysql_num_rows($moep);
$dropdown.="<select name='NAME'>";
for($i=0;$i<$num;$i++) {
$dsatz = mysql_fetch_assoc($moep);
$dropdown.="<option value='".$dsatz['FELD']."'>".$dsatz['FALDNAME']."</option>";
}
$dropdown.="</select>";
[/PHP]

ist allerdings ungetestet:rolleyes:

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.