Ich hatte mich letztens etwas unklar ausgedrückt - vielleicht mache ichs ja heute besser. Nehmen wir an, ich habe 20 Gästebucheinträge. Diese lese ich aus. Jetzt möchte ich aber nur 3 Einträge pro Seite haben, und für die restlichen 3er-Paare sollen Verweise ala zurück (2)(3)(4) weiter entstehen. Und wenn man dort auf die 4 klickt, dann sieht man halt die Einträge 10,11,12. Wie setzte ich das um? Muss ich da irgendwelche Schleifen nehmen. Wie generiert es mir automatisch eine neue Zahl, wenn ich z.B. den 22. Eintrag habe?
Homepage selbermachen 7.851 Themen, 35.616 Beiträge
hab ganz vergessen, dass Variablen zur Datenbankabfrage zurückgegeben werden bei erneutem Indexaufruf... ist im Gesamten vieleicht besser verständlich...
<?
include("inc/session.lib.php");
include("inc/db.lib.php");
include("oben.php");
$sql = "SELECT katID FROM kategorie";
$rslt = mysql($DBname, $sql);
if($kid && $ukid){
$sqlc = "SELECT prodID FROM products WHERE katID = '$kid' AND difKatID = '$ukid'";
$rsltc = mysql($DBname, $sqlc);
$num_rows = mysql_num_rows($rsltc);
$text = "<b>$num_rows Angebote $ukid </b>";
$lim_a = $lim_a + $lim;
$sqla = "SELECT prodID, prodPrice, prodBild FROM products WHERE katID = '$kid' AND difKatID = '$ukid' LIMIT $lim_a, 4";
$rslta = mysql($DBname, $sqla);
}
elseif($kid){
$sqla = "SELECT prodID, prodPrice, prodBild FROM products WHERE katID = '$kid' AND catch2 = 1";
$rslta = mysql($DBname, $sqla);
$text = "<b>Topangebote $kid </b><br>Alle Angebote links ";
}
else{
$sqla = "SELECT prodID, prodPrice, prodBild FROM products WHERE catch1 = 1";
$rslta = mysql($DBname, $sqla);
$text = "<b>Unsere Topangebote </b>";
}
?>
<!-- start page top -->
<table width="780" height="100%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td valign="top" background="pics/kachel1.gif">
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><td valign="top">
<table cellpadding="0" cellspacing="0" border="0" width="410"><tr>
<td class="nav2"><img src="pics/arb.gif" alt="" border="0"></td>
<td class="nav1"><a href="warenkorb.php"><span class="nav"> Warenkorb </span></a></td>
<td class="nav2"><img src="pics/arb.gif" alt="" border="0"></td>
<td class="nav1"><a href="index.php"><span class="nav"> Übersicht </span></a></td>
<td class="nav2"><img src="pics/arb.gif" alt="" border="0"></td>
<td class="nav1"><a href="impressum.php"><span class="nav"> Impressum </span></a></td>
<td class="nav2"><img src="pics/arb.gif" alt="" border="0"></td>
<td class="nav1"><a href="kontakt.php"><span class="nav"> Kontakt </span></a></td>
<td class="nav2"><img src="pics/arb.gif" alt="" border="0"></td>
<td class="nav1"><a href="agb.php"><span class="nav"> AGB's </span></a></td>
</tr></table>
</td>
<td align="right" width="370" valign="top">
<img src="pics/pic_unten.gif" alt="" border="0">
</td>
</tr></table>
<!-- end page top -->
<br>
<!-- start page org -->
<table border="0" align="center" height="30" width="780"><tr>
<td width="350">
<?
if($num_rows > 4){
echo "<table align=\"center\" border=\"0\"><tr>";
$s = ceil($num_rows / 4);
$x = 1;
$y = 0;
$o = 1;
while($x <= $s){
$u = (($lim + 4) / 4);
if($x == $u){
echo "
<td width=\"25\" align=\"center\" bgcolor=\"cadetblue\">
<div class=\"org1\"><b>$x</b></div>
</td>";
if($x < $s){
echo "<td><b>|</b></td>";
}
if($o == 8){
echo "</tr><tr>";
$o = 0;
}
$x = $x + 1;
$y = $y + 4;
$o = $o + 1;
}
else
{
echo "
<td width=\"25\" align=\"center\">
<a href=\"index.php?kid=" . $kid . "&ukid=" . $ukid . "&lim=" . $y . "\"><div class=\"org\"><b><u>$x</u></b></div></a>
</td>";
if($x < $s){
echo "<td><b>|</b></td>";
}
if($o == 8){
echo "</tr><tr>";
$o = 0;
}
$x = $x + 1;
$y = $y + 4;
$o = $o + 1;
}
}
echo "</tr></table>";
}
?>
</td>
<td width="90">
<?
if($lim_a >= 4){
$ii = $lim_a - 4;
echo "
<a href=\"index.php?kid=" . $kid . "&ukid=" . $ukid . "&lim=" . $ii . "\"><img src=\"pics/back.gif\" border=\"0\" align=\"middle\"><b>Zurück</b></a>";
}
?>
</td>
<td width="90" align="right">
<?
if($num_rows > 4){
if($lim_a + 4 < $num_rows){
$i = $lim_a + 4;
echo "
<a href=\"index.php?kid=" . $kid . "&ukid=" . $ukid . "&lim=" . $i . "\"><b>Weiter</b><img src=\"pics/vor.gif\" border=\"0\" align=\"middle\"></a>";
}
}
?>
</td>
<td width="300" align="right">
<?
echo "<span class=\"chap\">$text</span>";
?>
</td>
</tr></table>
<!-- end page org -->
<table width="780" border="0" align="center"><tr valign="top">
<!-- start navi left -->
<td valign=\"top\">
<?
while($row = mysql_fetch_array($rslt)){
echo "<table border=\"0\" width=\"180\"><tr><td bgcolor=\"\"><hr noshade size=\"2\"><img src=\"pics/ar.gif\" border=\"0\"><a href=\"index.php?kid=" . $row["katID"] . "\"><b>" . $row["katID"] . "</b></a></td></tr></table>";
if($kid == $row["katID"])
{
$rsltb = mysql($DBname, "SELECT katID,difKatID FROM difkat WHERE katID = '$kid'");
while($rowb = mysql_fetch_array($rsltb)){
if($ukid == $rowb["difKatID"])
{
echo "<table border=\"0\" width=\"180\"><tr><td width=\"30\"></td><td width=\"13\"><img src=\"pics/ar1.gif\" border=\"0\"></td><td><table bgcolor=\"#8CBABD\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><b><span class=\"chap\"> " . $rowb["difKatID"] . " </span></b></td></tr></table></td></tr></table>";
}
else{
echo "<table border=\"0\" width=\"180\"><tr><td width=\"30\"></td><td width=\"13\"><img src=\"pics/ar1.gif\" border=\"0\"></td><td><a href=\"index.php?kid=" . $rowb["katID"] . "&ukid=" . $rowb["difKatID"] . "\"><b>" . $rowb["difKatID"] . "</b></a></td></tr></table>";
}
}
}
else
{
}
}
?>
<table border="0" width="180"><tr><td><hr noshade size="2"></td></tr></table>
<!-- end navi left -->
<!-- start search -->
<table border="0" width="180"><tr><td>
<b><span class="chap1">Stichwortsuche</span></b></td></tr>
<form action="search.php" method="post">
<tr><td><input type="Text" name="word" value="" size="20" maxlength="20"></td></tr>
<tr><td height="50"><input type="Submit" name="" value=">> suchen">
</form>
</td></tr></table>
<!-- end search -->
</td><td width="30"></td>
<td>
<!-- start products -->
<table border="0">
<tr><td>
<?
$a = 2;
while ($rowa = mysql_fetch_array($rslta)){
if($a == 2){
echo "
<table border=\"0\" align=\"left\" width=\"270\"><tr>
<td><a href=\"bild.php?bid=" . $rowa[prodID] . "\"><img src=img/" . $rowa[prodBild] . " border=\"0\" alt=\"Vergrössern\"></a><br><table border=\"0\"><tr><td><a href=\"bild.php?bid=" . $rowa[prodID] . "\"><b>[ Details ]</b></a></td><td>[ $rowa[prodPrice] € ]</td><td><a href=\"addToCart.php?pid=". $rowa[prodID] ."\"><b>[ Bestellen ]</b></a></td></tr></table></td></tr></table>";
$a = 1;
}
else
{
echo "
<table border=\"0\"><tr>
<td><a href=\"bild.php?bid=" . $rowa[prodID] . "\"><img src=img/" . $rowa[prodBild] . " border=\"0\" alt=\"Vergrössern\"></a><br><table border=\"0\"><tr><td><a href=\"bild.php?bid=" . $rowa[prodID] . "\"><b>[ Details ]</b></a></td><td>[ $rowa[prodPrice] € ]</td><td><a href=\"addToCart.php?pid=". $rowa[prodID] ."\"><b>[ Bestellen ]</b></a></td></tr></table></td></tr></table><p><hr noshade size=\"1\"><p>";
$a = 2;
}
}
?>
<!-- end products -->
</td>
</tr>
</table></td></tr></table>
</td></tr></table>
<?
include("inc/footer.php");
?>
</body>
</html>