Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hi,

ich hab da nen Problem. Ich will, dass immer nur 6 Gästebucheinträge auf einer

Seite angezeigt werden. Also, hab ich das Script nen bissl modifiziert.

Funktioniert aber net richtig. Weiß net warum. Irgendwie passiert da gar nix...:(!

Hier mal der Code:


<?php
$host = "xxx";
$name = "xxx";
$passwort = "xxx";

$sql = mysql_connect($host, $name, $passwort);
$dbname = "xxx";
mysql_select_db($dbname);

if ($seite < 1) {
$seite = 1;
}

$seitenanzahl = $seite * 6;
$seitenanzahlminus = $seitenanzahl - 6;

$res = mysql_query( "select count(*) from `basti-wehr_gaestebuch`" );
$row = mysql_fetch_row($res);
$anzahl = $row[0];

$anfrage = mysql_query( "SELECT id,name,email,homepage,ort,nachricht FROM `basti-wehr_gaestebuch` ORDER BY id DESC LIMIT $seitenanzahlminus, $seitenanzahl" )
or die ( "Konnte Gästebuch nicht anzeigen: ".mysql_error() );
while ($datensatz = mysql_fetch_object($anfrage) AND $i <= 15){
$i = $i + 1;
print "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">";
print "<tr>";
print "</tr>";
print "<tr>";
print "<td width=\"11%\"><strong>Name:</strong></td>";
print "<td width=\"32%\">$datensatz->name</td>";
print "<td width=\"18%\"><strong>aus dem Ort:</strong></td>";
print "<td width=\"39%\">$datensatz->ort</td>";
print "</tr>";
print "<tr>";
print "<td><strong>E-Mail:</strong></td>";
print "<td><a href=\"mailto:$datensatz->email\">$datensatz->email</a></td>";
print "<td><strong>Homepage:</strong></td>";
print "<td><a href=\"$datensatz->homepage\">$datensatz->homepage</a></td>";
print "</tr>";
print "<tr>";
print "<td colspan=\"4\"><strong>Nachricht:</strong></td>";
print "</tr>";
print "<tr>";
print "<td colspan=\"4\"><font color=\"#333333\">$datensatz->nachricht</font></td>";
print "</tr>";
print "</table><br>";
}

$iMaxSites = ceil( $anzahl / 6);
for ( $i = 0; $i < $iMaxSites;) {
$i++;
echo "<a href='gaestebuch.php?seite=". $i ."'>[Seite ". $i . "]</a> ";
}
mysql_close($sql);
?>
[/PHP]

Das Gästebuch ist hier: http://basti-wehr.sebastian-muth.de/htm/guestbook.php

Ich hoffe, dass mir einer helfen kann. Schon mal Danke im Vorraus!

Gruß

Sebastian

Hi,

sorry. Wie meinst du das? Bin in PHP

net so der Profi...;)!

Trotzdem mal Danke!

Sebastian

So wie ich es geschrieben habe.


<?php
$host = "xxx";
$name = "xxx";
$passwort = "xxx";

$sql = mysql_connect($host, $name, $passwort);
$dbname = "xxx";
mysql_select_db($dbname);

if ($_GET['seite'] < 1) {
$_GET['seite'] = 1;
}

$seitenanzahl = $_GET['seite'] * 6;
$seitenanzahlminus = $seitenanzahl - 6;

$res = mysql_query( "select count(*) from `basti-wehr_gaestebuch`" );
$row = mysql_fetch_row($res);
$anzahl = $row[0];

$anfrage = mysql_query( "SELECT id,name,email,homepage,ort,nachricht FROM `basti-wehr_gaestebuch` ORDER BY id DESC LIMIT $seitenanzahlminus, $seitenanzahl" )
or die ( "Konnte Gästebuch nicht anzeigen: ".mysql_error() );
while ($datensatz = mysql_fetch_object($anfrage) AND $i <= 15){
$i = $i + 1;
print "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">";
print "<tr>";
print "</tr>";
print "<tr>";
print "<td width=\"11%\"><strong>Name:</strong></td>";
print "<td width=\"32%\">$datensatz->name</td>";
print "<td width=\"18%\"><strong>aus dem Ort:</strong></td>";
print "<td width=\"39%\">$datensatz->ort</td>";
print "</tr>";
print "<tr>";
print "<td><strong>E-Mail:</strong></td>";
print "<td><a href=\"mailto:$datensatz->email\">$datensatz->email</a></td>";
print "<td><strong>Homepage:</strong></td>";
print "<td><a href=\"$datensatz->homepage\">$datensatz->homepage</a></td>";
print "</tr>";
print "<tr>";
print "<td colspan=\"4\"><strong>Nachricht:</strong></td>";
print "</tr>";
print "<tr>";
print "<td colspan=\"4\"><font color=\"#333333\">$datensatz->nachricht</font></td>";
print "</tr>";
print "</table><br>";
}

$iMaxSites = ceil( $anzahl / 6);
for ( $i = 0; $i < $iMaxSites;) {
$i++;
echo "<a href='gaestebuch.php?seite=". $i ."'>[Seite ". $i . "]</a> ";
}
mysql_close($sql);
?>
[/php]

Frank


if ($seite < 1) {
$seite = 1;
}

$seitenanzahl = $seite * 6;
$seitenanzahlminus = $seitenanzahl - 6;
[/PHP]

Hier hast du deine Variable Seite, die du dir wahrscheinlich aus dem REQUEST holen willt, ist das richtig.

Wenn der Server nicht dafür eingestellt ist, kann er die Variable nicht empfangen und du musst sie aus dem Array $GET auslesen!

Versuch mal in der if Bedingung $seite mit $GET['seite'] zu ersetzen!

Oder lass dir überhaupt mal seite ausgeben, um zu sehen, ob die Seite übergeben wird!

Edit: War wohl zu spät

Danke.

Funktioniert jetzt...:)!

Gruß

Sebastian

Danke.

Funktioniert jetzt...:)!

Gruß

Sebastian

zur Erklärung:

da die Variabel 'seite' in der url eines Links oder in der Adressezeile erscheint, musst du diese mit $_GET['seite'] ansprechen. (Da die Variable dann ein sog. GET Parameter ist).

Variablen die du durch Formulare erhälst, werden als POST variablen bezeichnet, da sie (sofern method='post' gesetzt ist) per Absenden button "gepostet" werden. Diese sind dann im Array $_POST zu finden.

Weitere details dazu findest du im Google unter dem Stichwort "register globals"

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.