Hallo Leute,
ich habe einen Denkfehler in der Programmierung einer SQL-Datenbankabfrage.
Die abzufragende Tabelle ee_category_ger besteht aus drei Felder. ee_category_id, ee_category_name, ee_category_sub.
ee_category_sub legt fest, ob der Eintrag ein Hauptmenüpunkt ist (0), oder zu einer Unterkategorie gehört (1,2,3, usw.)
Das Menü wird mittels Javascript erstellt.
Folgendes Problem:
In den Untermenüs, erscheinen die Verlinkungen bei den jeweils ersten beiden Einträgen mit dem gleichen Link und bei den FolgeLinks jeweils um einen nach hinten versetzt.
Hier der komplette Code der Seite:
PHP-Code:
<?php require_once('Connections/DD.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_DD, $DD);
$query_rsMenue = "SELECT * FROM ee_category_ger WHERE ee_category_sub = '0'";
$rsMenue = mysql_query($query_rsMenue, $DD) or die(mysql_error());
$row_rsMenue = mysql_fetch_assoc($rsMenue);
$totalRows_rsMenue = mysql_num_rows($rsMenue);
$colname_c = "-1";
if (isset($row_rsMenue['ee_category_id'])) {
$colname_rsSubmenue = (get_magic_quotes_gpc()) ? $row_rsMenue['ee_category_id'] : addslashes($row_rsMenue['ee_category_id']);
}
mysql_select_db($database_DD, $DD);
$query_rsSubmenue = sprintf("SELECT * FROM ee_category_ger WHERE ee_category_sub = '%s'", GetSQLValueString($colname_rsSubmenue, "int"));
$rsSubmenue = mysql_query($query_rsSubmenue, $DD) or die(mysql_error());
$row_rsSubmenue = mysql_fetch_assoc($rsSubmenue);
$totalRows_rsSubmenue = mysql_num_rows($rsSubmenue);
?>
<?php
// RepeatSelectionCounter_1 Initialization
$RepeatSelectionCounter_1 = 0;
$RepeatSelectionCounterBasedLooping_1 = false;
$RepeatSelectionCounter_1_Iterations = "-1";
?>
<?php
// RepeatSelectionCounter_2 Initialization
$RepeatSelectionCounter_2 = 0;
$RepeatSelectionCounterBasedLooping_2 = false;
$RepeatSelectionCounter_2_Iterations = "-1";
?>
<!DOCTYPE HTML>
<html>
<head>
<link rel="shortcut icon" href="http://www.wlip.de/3Dpictures/images/favicon.ico" type="image/gif" />
<meta charset="utf-8">
<title>3Dpictures</title>
<link href="css/thrColLiqHdr.css" rel="stylesheet" type="text/css"><!--[if lte IE 7]>
<style>
.content { margin-right: -1px; } /* Dieser negative Rand mit 1 Pixel hat in jeder Spalte in diesem Layout die gleiche korrigierende Auswirkung. */
ul.nav a { zoom: 1; } /* Mit der zoom-Eigenschaft erhält IE den Auslöser hasLayout, der erforderlich ist, um den zusätzlichen Leerraum zwischen den Hyperlinks zu korrigieren. */
</style>
<![endif]-->
<link rel="stylesheet" type="text/css" href="Scripts/BarMenu.css">
<script type="text/javascript" src="Scripts/BarMenu.js"></script>
<style type=”text/css”>
.menu1{
background-image:url(images/menudiv1bg.gif);
margin-left:25px;
padding-left:20px;
padding-top:2px;
padding-bottom: 2px;
display:block;
text-decoration: none;
color: #000000;
height: 20px;
}
</style>
<style type=”text/css”>
.submenu{
background-image: url(images/submenu.gif);
display: block;
height: 19px;
margin-left: 38px;
padding-top: 2px;
padding-left: 7px;
color: #333333;
}
.hide{
display: none;
}
.show{
display: block;
}
</style>
<style type="text/css">
body,td,th {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
}
body {
background-color: #FFFFCC;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<p><a href="index.php"><img src="http://www.php.de/images/IIIDText.jpg" alt="Hier Logo einfügen" name="Insert_logo" width="250" height="127" id="Insert_logo" style="background: #8090AB; display:block; width: 250px;" />
</div> <!-- end .header -->
<div class="sidebar1">
<table cellspacing="0" cellpadding="0" id="bar-menu1" class="bar-menu">
<?php
// RepeatSelectionCounter_2 Begin Loop
$RepeatSelectionCounter_2_IterationsRemaining = $RepeatSelectionCounter_2_Iterations;
while($RepeatSelectionCounter_2_IterationsRemaining--){
if($RepeatSelectionCounterBasedLooping_2 || $row_rsMenue){
?>
<tr>
<td>
<div class="box1"><?php echo $row_rsMenue['ee_category_name']; ?><img src="http://www.php.de/images/arrow1.gif" width="11" height="11" alt=""></div>
<div class="section">
<div class="box2"><img src="http://www.php.de/images/arrow2.gif" width="14" height="9" alt=""><a href="photo.php?category=<?php echo $row_rsSubmenue['ee_category_name']; ?>">
<?php
// RepeatSelectionCounter_1 Begin Loop
$RepeatSelectionCounter_1_IterationsRemaining = $RepeatSelectionCounter_1_Iterations;
while($RepeatSelectionCounter_1_IterationsRemaining--){
if($RepeatSelectionCounterBasedLooping_1 || $row_rsSubmenue){
?>
<?php echo $row_rsSubmenue['ee_category_name']; ?></a></div>
<div class="box2"><img src="http://www.php.de/images/arrow2.gif" width="14" height="9" alt=""><a href="photo.php?category=<?php echo $row_rsSubmenue['ee_category_name']; ?>">
<?php
}
// RepeatSelectionCounter_1 Begin Alternate Content
else{
?>
<?php } // RepeatSelectionCounter_1 End Alternate Content
if(!$RepeatSelectionCounterBasedLooping_1 && $RepeatSelectionCounter_1_IterationsRemaining != 0){
if(!$row_rsSubmenue && $RepeatSelectionCounter_1_Iterations == -1){$RepeatSelectionCounter_1_IterationsRemaining = 0;}
$row_rsSubmenue = mysql_fetch_assoc($rsSubmenue);
}
$RepeatSelectionCounter_1++;
} // RepeatSelectionCounter_1 End Loop
?>
</a></div>
</div>
</td>
</tr>
<tr>
<td>
<?php
} // RepeatSelectionCounter_2 Begin Alternate Content
else{
?>
<?php } // RepeatSelectionCounter_2 End Alternate Content
if(!$RepeatSelectionCounterBasedLooping_2 && $RepeatSelectionCounter_2_IterationsRemaining != 0){
if(!$row_rsMenue && $RepeatSelectionCounter_2_Iterations == -1){$RepeatSelectionCounter_2_IterationsRemaining = 0;}
$row_rsMenue = mysql_fetch_assoc($rsMenue);
}
$RepeatSelectionCounter_2++;
} // RepeatSelectionCounter_2 End Loop
?>
</td>
</tr>
</table>
<script type="text/javascript">
var barMenu1 = new BarMenu('bar-menu1');
barMenu1.init();
</script>
</div> <!-- end .sidebar2 -->
<div class="content">
</div><!-- end .content -->
</div><!-- end .container -->
</body>
</html>
Vielleicht findet ja jemand von euch den Fehler.
Vielen Dank schon mal...