hi!
ich hab mal ein kleines skript geschrieben, welches ein menü aus einer mysqldatenbank auslesen soll und dies dann natürlich auch ausgibt.
nun habe ich folgendes skript:
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
| <?php
include "db.php";
$title = "SELECT * FROM `menutitle`";
$titles = mysql_query($title) or die("Zeile 8!");
$anztitle = mysql_num_rows($titles);
if($anztitle == 0) { print "Zeile 10!"; }
$i = "0";
while($row = mysql_fetch_assoc($titles)) {
$titelid[$i] = $row['id'];
$titel[$i] = $row['name'];
$i++;
}
for($j="0";$j<$anztitle;$j++) {
$menup{$j} = "SELECT * FROM `menupunkt`
WHERE `pid` = '$titleid[$j]'";
$menups{$j} = mysql_query($menu{$j}) or die(mysql_error());
$anzmenup{$j} = mysql_num_rows($menups{$j});
if($anzmenup{$j} == 0) { print "Zeile 22! j=$j"; }
for($k="0";$k<$anzmenup;$k++) {
$menupid{$j}[$k] = $row['id'];
$menuppid{$j}[$k] = $row['pid'];
$menupname{$j}[$k] = $row['name'];
$menupurl{$j}[$k] = $row['url'];
}
}
print '<table border="1px" cellspacing="0px">';
$i = "0";
while($i<$anztitle) {
print "<tr><th>$titel[$i]</th></tr>\n";
for($l="0";$l<$anzmenup{$i};$l++) {
print "<tr><td><a href=\"$menupurl{$i}[$l]\">$menupname{$i}[$l]</a></td></tr>\n";
}
$i++;
}
?> |
als ausgabe bekomme ich nur "Query was empty"... in der datenbank sind aber zum test je zwei einträge in jeder tabelle vorhanden... sieht jemand den fehler?
und kann dieses skript überhaupt funktionieren, oder habe ich irgend einen denkfehler drin gemacht?
cYa kJ'