Ich möchte aus einer DB-Tabelle Begriffe heraussuchen und
alphabetisch mit vorangestelltem großen "A" oder "B" etc.
anzeigen lassen.
Ich bekomme die Anzeige, unterteilt nach Buchstaben, nicht hin. Da muss irgend eine Schleife mit rein. Ich weiss aber nicht wie.
Ich habe mal den Code reingestellt. Vielleicht weiss jemand etwas.
Im Beispiel werden alle Begriffe zu "A" angezeigt.
Lasse ich ($anfang=="A")
weg, kommen alle Begriffe, die in der Datentabelle sind.
- Code: Select all
?>
<body bgcolor="#E8E8FF" vlink="#C04040" link="#C04040">
<table align="center" class="buchstaben">
<tr>
<td><a target="_self" href="#A">A</a></td>
<td><a target="_self" href="#B">B</a></td>
<td><a target="_self" href="#C">C</a></td>
<td><a target="_self" href="#D">D</a></td>
<td><a target="_self" href="#E">E</a></td>
<td><a target="_self" href="#F">F</a></td>
<td><a target="_self" href="#G">G</a></td>
<td><a target="_self" href="#H">H</a></td>
<td><a target="_self" href="#I">I</a></td>
<td><a target="_self" href="#J">J</a></td>
<td><a target="_self" href="#K">K</a></td>
<td><a target="_self" href="#L">L</a></td>
<td><a target="_self" href="#M">M</a></td>
<td><a target="_self" href="#N">N</a></td>
<td><a target="_self" href="#O">O</a></td>
<td><a target="_self" href="#P">P</a></td>
<td><a target="_self" href="#Q">Q</a></td>
<td><a target="_self" href="#R">R</a></td>
<td><a target="_self" href="#S">S</a></td>
<td><a target="_self" href="#T">T</a></td>
<td><a target="_self" href="#U">U</a></td>
<td><a target="_self" href="#V">V</a></td>
<td><a target="_self" href="#W">W</a></td>
<td><a target="_self" href="#X">X</a></td>
<td><a target="_self" href="#Z">Z</a></td>
</tr>
</table>
<table>
<dl class="ueba">
<dt>
<a href="#top" target="_self" name="A">
<br>
<h3><i> - A - </i></h3>
</dt>
<?php
while($d = mysql_fetch_array($result))
{
while(list($k, $v) = each($d))
{
if ((isset($v)) & ($k==='swlangname'))
{
$anfang=(substr($v,0,1));
if ((!($v==$vorgaenger)) and ($anfang=="A"))
{
$b++;
$a++;
if ($value1)
{
$wert1=$value1;
$wert2=$v;
}
else {$wert1="$v"; $wert2=""; }
if (($a % 30) == 1)
print ("</font></td><td valign=top><font face='Arial' size='2' color='#0000a0'>");
print ("<a href='stichwort.php?wert1=$wert1&wert2=$wert2' title='$d[swlangname]'>". ucfirst($v)." </a><br>");
}
$vorgaenger=$v;
}
}
}
// am ende aller stichwörter //
print "____________________________________________________";
print "<p align='center'><a href='javascript:history.go(-1)'>zurück zum Anfang</a></p>";
print ("</font></td></tr></table>");