You are not logged in.

  • Login

Dear visitor, welcome to Coder Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Tuesday, December 26th 2006, 5:24pm

PHP und Pulldown Menüs

hallo,
ich hab mal wieder ein etwas größeres problem. ich möchte ein pulldown menue erstellen, (im html editor heißt das Liste). die einträge sollen aus einer datenbank erfolgen, die 24 euinträge aufweist.

<td>Fahrer 1</td><td><select name="" size="">
<option> M. Schumacher &nbsp;/&nbsp;13 Mio</option>
<option> R. Barrichello &nbsp;/&nbsp;13 Mio</option>
<option> J. Button &nbsp;/&nbsp;13 Mio</option>
<option> T. Sato &nbsp;/&nbsp;13 Mio</option>
<option> F. Alonso &nbsp;/&nbsp;13 Mio</option>
<option> G. Fisichella &nbsp;/&nbsp;13 Mio</option>
<option> M. Webber &nbsp;/&nbsp;13 Mio</option>
<option> N. Heidfeld &nbsp;/&nbsp;13 Mio</option>
<option> J.-P. Montoya &nbsp;/&nbsp;13 Mio</option>
<option> K. Raikkönen &nbsp;/&nbsp;13 Mio</option>
<option> J. Villeneuve &nbsp;/&nbsp;13 Mio</option>
<option> F. Massa &nbsp;/&nbsp;13 Mio</option>
<option> D. Coulthard &nbsp;/&nbsp;13 Mio</option>
<option> Ch. Klien &nbsp;/&nbsp;13 Mio</option>
<option> J. Trulli &nbsp;/&nbsp;13 Mio</option>
<option> R. Schumacher &nbsp;/&nbsp;13 Mio</option>
<option> T. Monteiro &nbsp;/&nbsp;13 Mio</option>
<option> N. Karthikeyan &nbsp;/&nbsp;13 Mio</option>
<option> Ch. Albers &nbsp;/&nbsp;13 Mio</option>
<option> P. Friesacher &nbsp;/&nbsp;13 Mio</option>
</select></td>

so in etwa soll es nachher aussehen. allerdings hab ich da noch ne kleinigkeit. wenn mann den namen des eintrages ausgewählt hat, soll hinter dem menue der preis des fahrers stehen der auch aus der db kommen soll.
ich hoffe ich hab das einigermaßen gut erklärt. wäre echjt dankbar für eine hilfe. in büchern hab ich sowas noch nicht gefunden.

einen guten rutsch wünsch ich euch

holger

2

Tuesday, December 26th 2006, 6:03pm

Hi, das ist simpel

PHP Quellcode

1
2
3
4
$res = mysql_query("SELECT id,name,preis FROM tabelle");
while($row=mysql_fetch_object($res)) {
  echo '<option value="'.$row->id.'">'.$row->name.'&nbsp;/&nbsp; '.$row->preis.'</option>';
}

3

Tuesday, December 26th 2006, 11:31pm

Wenn er jedoch das nicht dierekt in der Liste haben möchte muss du dazu noch ein Java Script benutzen oder gar Ajax.

Also das nur wenn das extra angezeigt werden soll in einem Text feld oder ähnlichem und nicht dierekt in der Select Box

4

Saturday, December 30th 2006, 2:55pm

noch ne nachfrage

hallo, erstnmal vielen dank für die schnelle antwort. ich habe jetzt ein problem mit dem code, meine datei lässt sich so nicht anzeigen. er schmeißt mir immer einen fehler raus. ich poste mal die datei und den dazugehörigen fehler:

HTML Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<html>
<head>
<title>Testung</title>
<meta name="author" content="Dieter">
<meta name="generator" content="Ulli Meybohms HTML EDITOR">
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#FF0000" alink="#FF0000" vlink="#FF0000">
 
 
 
<div align="center"><b><u><h1>Änderung des Teams</h1></u></b></div>
<?php
include ("dbcon.php") ;
 
echo '<div align="center"><b><h2>Teamname</h2></b></div>;
<div align="center"><u><b><h2>'. $row ['teamname'] .'</h2></b></u></div>
 
<div align="center"><b><h2>E-Mail Adresse</h2></b></div>
<div align="center"><u><b><h2>'. $row ['email'] .'</h2></b></u></div>
 
<table>
 
 
 
<td>
<table>
   <tr><div align="center"><h2><u>Verkaufen</u></h2></div></tr>
 
        <tr>
                <td>Fahrer 1:</td>
                <td><b>'.$row['fahrer_1'].'</b></td>
                <td><b>'.$row['f1-mio'].'</b></td>
                <td>Mio.</td>
                <td><input type="Checkbox" name="1" value="v"></td>
        </tr>
 
        <tr>
                <td>Fahrer 2:</td>
                <td><b>'.$row['fahrer_2'].'</b></td>
                <td><b>'.$row['f2-mio'].'</b></td>
                <td>Mio.</td>
                <td><input type="Checkbox" name="2" value="v"></td>
        </tr>
 
                <tr>
                <td>Chassis:</td>
                <td><b>'.$row['chassis'].'</b></td>
                <td><b>'.$row['ch-mio'].'</b></td>
                <td>Mio.</td>
                <td><input type="Checkbox" name="3" value="v"></td>
        </tr>
 
                <tr>
                <td>Motor:</td>
                <td><b>'.$row['motor'].'</b></td>
                <td><b>'.$row['m-mio'].'</b></td>
                <td>Mio.</td>
                <td><input type="Checkbox" name="4" value="v"></td>
        </tr>
 
                <tr>
                <td>Restbudget:</td>
                <td></td>
                <td><b>'.$row['restbudget'].'</b></td>
                <td>Mio.</td>
        </tr>
        </table></td>
 
 
 
<td>
<table>
   <tr><div align="center"><h2><u>Kaufen</u></h2></div></tr>
 
$res = mysql_query("SELECT * FROM fahrer");
while($row=mysql_fetch_object($res)) {
 
}
 
        <tr>
<td>Fahrer 1</td><td><select name="" size="">
  echo '<option value="'.$row->f_id.'">'.$row->f_name.'&nbsp;&nbsp; '.$row->f_preis.'&nbsp;/&nbsp; '.$row->f_mio.'</option>';
     </select></td>
        </tr>
 
        <tr>
                <td>Fahrer 2:</td>
                <td><b>'.$row['fahrer_2'].'</b></td>
                <td><b>'.$row['f2-mio'].'</b></td>
                <td>Mio.</td>
                <td><input type="Checkbox" name="2" value="v"></td>
        </tr>
 
                <tr>
                <td>Chassis:</td>
                <td><b>'.$row['chassis'].'</b></td>
                <td><b>'.$row['ch-mio'].'</b></td>
                <td>Mio.</td>
                <td><input type="Checkbox" name="3" value="v"></td>
        </tr>
 
                <tr>
                <td>Motor:</td>
                <td><b>'.$row['motor'].'</b></td>
                <td><b>'.$row['m-mio'].'</b></td>
                <td>Mio.</td>
                <td><input type="Checkbox" name="4" value="v"></td>
        </tr>
 
                <tr>
                <td>Restbudget:</td>
                <td></td>
                <td><b>'.$row['restbudget'].'</b></td>
                <td>Mio.</td>
        </tr>
        </table></td>
 
 
 
 </table>
 ?>
 
 
 
 
  <div align="center"><input name="Send" type="submit" value="Abschicken">    <input name="Reset" type="reset" value="Löschen"></div>
 
 
 
</body>
</html>


und der fehler lautet:

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /srv/www/web223/html/Formel-1-Manager/Testung.php on line 82

ich kann damit mal wieder nichts anfangen. es kann auch sein das ich vorher irgendwo etwas falsch habe, kann das mal einer kontrollieren? wäre echt nett von euch.

holger einen guten rutsch ins neue Jahr

5

Saturday, December 30th 2006, 3:00pm

habe deinem code mal syntaxhighlighting verpasst.

Also 3 grundlegende Fehler sind mir auf den ersten Blick aufgefallen sind:
* Schau dir mal #15 und #73 genauer an.
* Und danach #80, #81
* Außerdem #82, #83, #120

HTML Code musst du in echos ausgeben.

6

Saturday, December 30th 2006, 3:23pm

versteh ich nicht richtig

hi d0nUt,

ich verstehe das nicht so recht, muss ich in jeder zeile ein echo davorsetzen? in der zeile 15 habe ich zum schluß ein hochkomma gesetzt ist das so richtig?

holger

7

Saturday, December 30th 2006, 4:35pm

nein, in jeder zeile nicht.

falsch:

Source code

1
2
3
<?php
<html>
?>


richtig:

Source code

1
2
3
<?php
echo '<html>';
?>


ersetzte deine Zeilen #72 bis #83 einfach mal durch meine:

Source code

1
2
3
4
5
6
7
8
9
10
   <tr><div align="center"><h2><u>Kaufen</u></h2></div></tr>
   <tr>
<td>Fahrer 1</td><td><select name="" size="">';

$res = mysql_query("SELECT * FROM fahrer");
while($row=mysql_fetch_object($res)) {
	echo '<option value="'.$row->f_id.'">'.$row->f_name.'&nbsp;&nbsp; '.$row->f_preis.'&nbsp;/&nbsp; '.$row->f_mio.'</option>';
}

echo '</select></td>

8

Saturday, December 30th 2006, 8:47pm

danke

danke, für die antwort und dem stück code, jetzt nach noch einer kleinen änderung hat es geklappt. ich habe aber noch mehr probleme mit der seite, wenn ich nicht weiter komme, werde ich mich wieder an euch wenden. das ist das beste forum wo gibt.
ein erfolgreiches 2007

holger

Social bookmarks