Kleines Problem mit Gästebuch

Alles, was PHP betrifft, kann hier besprochen werden.

Kleines Problem mit Gästebuch

Postby Adenauer1 » 20. June 2006 11:19

Hallo ich hab hier mal ein Gästebuchtuturial durchgeabreitet.
Soweit tut auch alles wunderbar.
Nur würd ich gerne dass die neuesten Einträge als erstes angezeigt werden.
Hab bei der SQL Abfrage das Order by von asc schon in DESC geändert aber bei der Ausgabe tut sich nichts.
Wäre nett wenn mal eben jemand drüber gucken kann danke.
Code: Select all
<?php
include("Menue.php");
    include("functions.inc.php");

    if ( isset( $_REQUEST["seite"] ) && $_REQUEST["seite"] != "" )
    {
   $seite   =   $_REQUEST["seite"];
    }
    else
    {
   $seite   =   1;
    }


    mysqlconnect();
   
    // Bestimmen der Einträge-Anzahl
    $gesamt      =   howmany();
    $seitengesamt   =   ceil( $gesamt / 5 );
 
    $offset   =   ( $seite - 1 ) * 5;
   
   
    $query   =   "SELECT * FROM eintraege ORDER BY id ASC LIMIT " . $offset . ", 5";
   
    $result   =   mysql_query( $query );
   
    if ( ! $result )
    {
       die("Konnte die Datens&auml;tze nicht auslesen");
    }

    $anzahl   =   mysql_num_rows( $result );
   
   
   
   
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

   <head>
      <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
      <meta name="generator" content="Adobe GoLive 6">
      <title>Willkommen bei Adobe GoLive 6</title>
      <style type="text/css" media="screen"><!--
body { font-family: Arial, Helvetica, Geneva, Swiss, SunSans-Regular }
a { color: red; text-decoration: none }
a:hover { text-decoration: underline }
.fliesstext { font-size: small }
.titel { font-weight: bold }
.beschr_hell { color: #ccc; font-weight: bold }
.maintitle  { color: gray; font-weight: bold; font-size: large }
--></style>
   </head>

   <body bgcolor="#ffffff">
      <table width="545" border="0" cellspacing="0" cellpadding="2">
         <tr>
            <td colspan="3" align="center" width="541">
               <p class="maintitle">HumpenPumpen Gästebuch</p>
            </td>
         </tr>
         <tr>
            <td width="45">&nbsp;</td>
            <td width="388">&nbsp;</td>
            <td width="100">&nbsp;</td>
         </tr>
         <tr>
            <td width="45"></">Home</a></td>
            <td align="center" width="388"><a href="new.php">Neuer Eintrag</a></td>
            <td width="100"><a href="admin.php"></a></td>
         </tr>
      </table>
      <p></p>
      <table width="550" border="0" cellspacing="0" cellpadding="2">
      <?php
          // Schleife zum Ausgeben der einzelnen Datensätze in Tabellen-Reihen
          for ( $i=1; $i <= $anzahl; $i++)
          {
         $datensatz   =   mysql_fetch_array( $result );
               
      ?>
      
         <tr>
            <td class="beschr_hell" align="left" valign="top" bgcolor="#666666" width="80">Datum</td>
            <td class="beschr_hell" align="left" valign="top" bgcolor="#666666" width="363">&nbsp;</td>
            <td class="beschr_hell" align="left" valign="top" bgcolor="#666666" width="95">Autor</td>
         </tr>
         <tr>
            <td align="left" valign="top" bgcolor="#cccccc" width="80"><?php echo $datensatz["Datum"]; ?></td>
            <td align="left" valign="top" bgcolor="#cccccc" width="363">&nbsp;</td>
            <td align="left" valign="top" bgcolor="#cccccc" width="95">
            
            <a href="<?php
                if ( $datensatz["Email"] != "" )
                {
               echo "mailto: " . $datensatz["Email"];
                }
                else
                {
               echo "#";
                }; ?>">
            
            
            <?php echo $datensatz["Autor"]; ?></a></td>
         </tr>
         <tr>
            <td align="left" valign="top" bgcolor="#999999" width="80">&nbsp;</td>
            <td align="left" valign="top" bgcolor="#999999" width="363">&nbsp;</td>
            <td align="left" valign="top" bgcolor="#999999" width="95">&nbsp;</td>
         </tr>
         <tr>
            <td class="beschr_hell" align="left" valign="top" bgcolor="#999999" width="80">Titel</td>
            <td colspan="2" align="left" valign="top" bgcolor="#cccccc" width="462">
               <p class="titel"><?php echo $datensatz["Titel"]; ?></p>
            </td>
         </tr>
         <tr>
            <td align="left" valign="top" bgcolor="#999999" width="80">&nbsp;</td>
            <td align="left" valign="top" bgcolor="#cccccc" width="363">&nbsp;</td>
            <td align="left" valign="top" bgcolor="#cccccc" width="95">&nbsp;</td>
         </tr>
         <tr>
            <td class="beschr_hell" align="left" valign="top" bgcolor="#999999" width="80">Text</td>
            <td colspan="2" align="left" valign="top" bgcolor="#cccccc" width="462">
               <p class="fliesstext"><?php echo $datensatz["Text"]; ?></p>
            </td>
         </tr>
         <tr>
            <td align="left" valign="top" bgcolor="#999999" width="80">&nbsp;</td>
            <td align="left" valign="top" bgcolor="#cccccc" width="363">&nbsp;</td>
            <td align="left" valign="top" bgcolor="#cccccc" width="95">&nbsp;</td>
         </tr>
         <tr>
            <td align="left" valign="top" width="80">&nbsp;</td>
            <td align="left" valign="top" width="363">&nbsp;</td>
            <td align="left" valign="top" width="95">&nbsp;</td>
         </tr>
         <?php
             }
         
         
         
         ?>
         <tr>
            <td align="left" valign="top" bgcolor="#999999" width="80">
            <?php
                if ( $seite != 1 )
                {
            ?>
            <a href="<?php echo $_REQUEST["PHP_SELF"]; ?>?seite=<?php echo $seite - 1; ?>">zur&uuml;ck</a>
            <?php
                }
            ?>
            </td>
            <td align="center" valign="top" bgcolor="#cccccc" width="363">Seite <?php echo $seite; ?> von <?php echo $seitengesamt; ?></td>
            <td align="right" valign="top" bgcolor="#cccccc" width="95">
            <?php
                if ( ( $seite +1 ) <= $seitengesamt )
                {
            ?>
            <a href="<?php echo $_REQUEST["PHP_SELF"]; ?>?seite=<?php echo $seite + 1; ?>">weiter</a>
            <?php
                }
            ?>
            </td>
         </tr>
      </table>
      <p></p>
      <p></p>
   </body>

</html>
Adenauer1
 
Posts: 25
Joined: 24. February 2006 18:09

Postby Wiedmann » 20. June 2006 11:36

Hab bei der SQL Abfrage das Order by von asc schon in DESC geändert

Wo hast du das? Seh ich im Script nirgends...
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby Adenauer1 » 20. June 2006 11:40

zeile 24 sollte es sein
Adenauer1
 
Posts: 25
Joined: 24. February 2006 18:09

Postby Adenauer1 » 20. June 2006 11:41

Sorry hat sich erledigt hab nur ein Autoincremet vergessen.
Na dann ist es kein wunder das ich immer die selbe sortierung bekommen wenn id immer 0 ist.
Adenauer1
 
Posts: 25
Joined: 24. February 2006 18:09


Return to PHP

Who is online

Users browsing this forum: No registered users and 61 guests