Kullakeeeks
Okay, nun habe ich den richtigen Code, allerdings wäre es nun noch schön, wenn man den Namen mit dem Steckbrief verlinken könnte.
Nur wie stellt man das an, weil es ja verschiedene IDs bei den Pferden gibt?!?!
Hier erstmal der aktuelle Code, in den noch die Verlinkung eingefügt werden muss:
php: |
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:
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>Ponyhof Ivanhoe</title>
</head>
<body>
<center>
Nur Pferde anzeigen mit<br>
Geschlecht: <a href="http://ponyhofivanhoe.bplaced.de/pferde/pony/stute.php">Stute</a>
- <a href="hengst.php">Hengst</a> - <a href="wallach.php">Wallach</a><br>
Haupteignung: Dressur - Springen - Vielseitigkeit - Western<br>
<table width="90%">
<tbody>
<tr>
<th width="15%"><b>Vorschau</b></th>
<th width="15%"><b>Name</b></th>
<th width="15%"><b>Rasse</b></th>
<th width="15%"><b>Geschlecht</b></th>
<th width="15%"><b>Alter</b></th>
<th width="15%"><b>Preis</b></th>
</tr>
<?php include("db.php"); $abfrage = "SELECT * FROM pferd WHERE Besitzer = ''";
$ergebnis = mysql_query($abfrage);
while($row = mysql_fetch_array($ergebnis))
{ ?>
<tr>
<td width="15%"><?php echo " <img src="".$row["Vorschaubild"]."">";
?>
</td>
<td width="15%"><?php echo $row["Name"]; ?></td>
<td width="15%"><?php echo $row["Rasse"];; ?></td>
<td width="15%"><?php echo $row["Geschlecht"]; ?></td>
<td width="15%">*<?php echo $row["Alter"]; ?></td>
<td width="15%"><?php echo $row["Wert"]; ?>€</td>
</tr>
<?php } ?>
</tbody>
</table>
</center>
</body>
</html>
|
|
Kullakeeeks
Habs geändert, geht aber immernoch nicht...
php: |
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:
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" type="text/css"
href="style.css">
<title>Ponyhof Ivanhoe</title>
</head>
<body>
<center>
<table width="90%">
<tbody>
<tr>
<th width="15%"><b>Vorschau</b></th>
<th width="15%"><b>Name</b></th>
<th width="15%"><b>Rasse</b></th>
<th width="15%"><b>Geschlecht</b></th>
<th width="15%"><b>Alter</b></th>
<th width="15%"><b>Preis</b></th>
</tr>
<?php include("db.php"); $abfrage = "SELECT * FROM pferd WHERE Besitzer = '' ORDER BY id LIMIT ".$seite.",".$proseite; // Datenabfrage
$ergebnis = mysql_query($abfrage);
while($row = mysql_fetch_object($ergebnis))
{ ?>
<tr>
<td width="15%"> <img
src="%3C?=%20$row-%3Evorschaubild%20?%3E"></td>
<td width="15%"><?php echo"$row[Name]" ?></td>
<td width="15%"><?php echo"$row[Rasse]" ?></td>
<td width="15%"><?php echo"$row[Geschlecht]" ?></td>
<td width="15%"><?php echo"$row[Alter]" ?></td>
<td width="15%"><?php echo"$row[Preis]" ?></td>
</tr>
<?php }
?>
</tbody>
</table>
</center>
</body>
</html>
|
|
Skadi
Probier mal anstatt $row[SPALTE], $row->SPALTE ;D
Mfg; Skadi
kext
Die Funktion mysql_fetch_object gibt, wie der Name schon sagt, ein Objekt zurück und kein Array. Auf Eigenschaften eines Objekts greift man mit -> zu, also $row->id. Besser ist aber, wenn du einfach mysql_fetch_array benutzt.
Mal ganz davon abgesehen schlägt schon die Abfrage fehl, da $seite und $proseite nicht definiert sind.
Kullakeeeks
Okay, ich hab den Code von meinem alten vRh genommen...
Wie muss ich $seite und $proseite denn definieren?
Skadi
Was willst du denn damit sagen?
kext
Bei LIMIT gibst du an, welcher der erste Datensatz sein soll (beginnend bei null), gefolgt von der Anzahl der Einträge.
LIMIT 0, 10 zeigt die ersten zehn Einträge.
LIMIT 5, 5 zeigt die Einträge 5, 6, 7, 8, 9 und 10.
Für Seite $seite mit $proseite Einträge ist das also:
$abfrage = "... LIMIT ".(($seite - 1) * $proseite).", ".$proseite;
Kullakeeeks
Keine Ahnung, das war im Code, den meine damalige MB erstellt hat, ich hab ihn einfach übernommen und mit meinen daten angepasst soweit...
Sieht da so aus:
klick
LG
Kuhmuhphu
Zitat: |
Original von Mutzelchen
Hast du die Datenbankzugangsdaten richtig eingegeben? |
Das wollte ich auch gerade fragen.. denn die Fehlermeldungen vor der Tabelle sind typisch für falsche Verbindungsdaten
Kullakeeeks
Ja, die stimmen, für die Steckbriefe nutz ich auch "db.php" und da gehts ja auch...
Kullakeeeks
php: |
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:
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" type="text/css"
href="style.css">
<title>Ponyhof Ivanhoe</title>
</head>
<body>
<center>
<table width="90%">
<tbody>
<tr>
<th width="15%"><b>Vorschau</b></th>
<th width="15%"><b>Name</b></th>
<th width="15%"><b>Rasse</b></th>
<th width="15%"><b>Geschlecht</b></th>
<th width="15%"><b>Alter</b></th>
<th width="15%"><b>Preis</b></th>
</tr>
<?php include("db.php"); $abfrage = "SELECT * FROM pferd WHERE Besitzer = '' ORDER BY id LIMIT ".$seite.",".$proseite; // Datenabfrage
$ergebnis = mysql_query($abfrage);
while($row = mysql_fetch_object($ergebnis))
{ ?>
<tr>
<td width="15%"> <img
src="%3C?=%20$row-%3Evorschaubild%20?%3E"></td>
<td width="15%"><?php echo"$row[Name]" ?></td>
<td width="15%"><?php echo"$row[Rasse]" ?></td>
<td width="15%"><?php echo"$row[Geschlecht]" ?></td>
<td width="15%"><?php echo"$row[Alter]" ?></td>
<td width="15%"><?php echo"$row[Preis]" ?></td>
</tr>
<?php }
?>
</tbody>
</table>
</center>
</body>
</html>
|
|
Kullakeeeks
Erledigt, jetzt kommt das:
"Fatal error: Call to a member function mysql_fetch_object() on a non-object in /users/ponyhofivanhoe/www/pferde/pony/verkaufspferde.php on line 37"
Code:
php: |
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:
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" type="text/css"
href="style.css">
<title>Ponyhof Ivanhoe</title>
</head>
<body>
<center>
<table width="90%">
<tbody>
<tr>
<th width="15%"><b>Vorschau</b></th>
<th width="15%"><b>Name</b></th>
<th width="15%"><b>Rasse</b></th>
<th width="15%"><b>Geschlecht</b></th>
<th width="15%"><b>Alter</b></th>
<th width="15%"><b>Preis</b></th>
</tr>
<?php include("db.php"); $abfrage = "SELECT * FROM pferd WHERE Besitzer = '' ORDER BY id LIMIT ".$seite.",".$proseite; // Datenabfrage
$ergebnis = mysql_query($abfrage);
while($row -> mysql_fetch_object($ergebnis))
{ ?>
<tr>
<td width="15%"> <img
src="%3C?=%20$row-%3Evorschaubild%20?%3E"></td>
<td width="15%"><?php echo"$row->Name"; ?></td>
<td width="15%"><?php echo"$row->Rasse"; ?></td>
<td width="15%"><?php echo"$row->Geschlecht"; ?></td>
<td width="15%"><?php echo"$row->Alter"; ?></td>
<td width="15%"><?php echo"$row->Preis"; ?></td>
</tr>
<?php }
?>
</tbody>
</table>
</center>
</body>
</html>
|
|
Kullakeeeks
Naja...irgendwas ist immernoch falsch...
php: |
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:
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" type="text/css"
href="style.css">
<title>Ponyhof Ivanhoe</title>
</head>
<body>
<center>
<table width="90%">
<tbody>
<tr>
<th width="15%"><b>Vorschau</b></th>
<th width="15%"><b>Name</b></th>
<th width="15%"><b>Rasse</b></th>
<th width="15%"><b>Geschlecht</b></th>
<th width="15%"><b>Alter</b></th>
<th width="15%"><b>Preis</b></th>
</tr>
<?php include("db.php"); $abfrage = "SELECT * FROM pferd WHERE Besitzer = ''
$ergebnis = mysql_query($abfrage);
while($row -> mysql_fetch_object($ergebnis))
{ ?>
<tr>
<td width="15%"> <img
src="%3C?=%20$row-%3Evorschaubild%20?%3E"></td>
<td width="15%"><?php echo"$row->Name"; ?></td>
<td width="15%"><?php echo"$row->Rasse"; ?></td>
<td width="15%"><?php echo"$row->Geschlecht"; ?></td>
<td width="15%"><?php echo"$row->Alter"; ?></td>
<td width="15%"><?php echo"$row->Preis"; ?></td>
</tr>
<?php }
?>
</tbody>
</table>
</center>
</body>
</html>
|
|
=> Parse error: syntax error, unexpected T_LNUMBER in /users/ponyhofivanhoe/www/pferde/pony/verkaufspferde.php on line 41
Kullakeeeks
Also ich hab jetzt alles umgesetzt, aber es geht trotzdem nicht...
php: |
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:
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" type="text/css"
href="style.css">
<title>Ponyhof Ivanhoe</title>
</head>
<body>
<center>
<table width="90%">
<tbody>
<tr>
<th width="15%"><b>Vorschau</b></th>
<th width="15%"><b>Name</b></th>
<th width="15%"><b>Rasse</b></th>
<th width="15%"><b>Geschlecht</b></th>
<th width="15%"><b>Alter</b></th>
<th width="15%"><b>Preis</b></th>
</tr>
<?php include("db.php"); $abfrage = "SELECT * FROM pferd WHERE Besitzer = ''"
$ergebnis = mysql_query($abfrage);
while($row -> mysql_fetch_object($ergebnis))
{ ?>
<tr>
<td width="15%"><?php echo" <img src="".$row[Vorschaubild]."">";
?>
</td>
<td width="15%"><?php echo"$row->"Name"; ?></td>
<td width="15%"><?php echo"$row->"Rasse"; ?></td>
<td width="15%"><?php echo"$row->"Geschlecht"; ?></td>
<td width="15%"><?php echo"$row->"Alter"; ?></td>
<td width="15%"><?php echo"$row->"Preis"; ?></td>
</tr>
</tbody>
</table>
</center>
</body>
</html>
|
|
=> Parse error: syntax error, unexpected T_VARIABLE in /users/ponyhofivanhoe/www/pferde/pony/verkaufspferde.php on line 36
Kullakeeeks
nope...
"Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_STRING or T_VARIABLE or '{' or '$' in /users/ponyhofivanhoe/www/pferde/pony/verkaufspferde.php on line 41"
Kullakeeeks
Muss da nur ein ; hinter?
Kullakeeeks
Es ändert sich nichts, egal, wo ich die Klammer schließe...
Kullakeeeks
Ja schon, aber die Klammer steht ja schon in nem php-Tag, also die php-Tags gehen alle auf und zu, nur die doofe Klammer geht nicht wieder zu, aber die Tags sind vollständig...
Kullakeeeks
Also ich hab das while jetzt in nen eigenen tag gepackt...
Aber die Klammwer ist immernoch alleine...
php: |
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:
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" type="text/css"
href="style.css">
<title>Ponyhof Ivanhoe</title>
</head>
<body>
<center>
<table width="90%">
<tbody>
<tr>
<th width="15%"><b>Vorschau</b></th>
<th width="15%"><b>Name</b></th>
<th width="15%"><b>Rasse</b></th>
<th width="15%"><b>Geschlecht</b></th>
<th width="15%"><b>Alter</b></th>
<th width="15%"><b>Preis</b></th>
</tr>
<?php include("db.php"); $abfrage = "SELECT * FROM pferd WHERE Besitzer = ''";
$ergebnis = mysql_query($abfrage); ?>
<?php while($row -> mysql_fetch_object($ergebnis));
{ ?><tr>
<td width="15%"><?php echo " <img src="".$row->"Vorschaubild"."">";
?>
</td>
<td width="15%"><?php echo $row->"Name"; ?></td>
<td width="15%"><?php echo $row->"Rasse"; ?></td>
<td width="15%"><?php echo $row->"Geschlecht"; ?></td>
<td width="15%"><?php echo $row->"Alter"; ?></td>
<td width="15%"><?php echo $row->"Preis"; ?></td>
</tr>
</tbody>
</table>
</center>
</body>
</html>
|
|
Kullakeeeks
Ich habs jetzt eingefügt, aber es kommt immernoch das:
"Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_STRING or T_VARIABLE or '{' or '$' in /users/ponyhofivanhoe/www/pferde/pony/verkaufspferde.php on line 41"