phpbar.de logo

Mailinglisten-Archive

[php] =?iso-8859-1?Q?Re:_=5Bphp=5D_Re:_=5Bphp=5D_Seitenweise_bl=E4ttern?=

[php] Re: [php] Re: [php] Seitenweise blättern

Bernd Beer php_(at)_phpcenter.de
Wed, 8 Aug 2001 16:55:26 +0200


hi mona,

ich habe bei meinem script die datenbankverbindung in externe dateien
ausgelagert.
ausserdem arbeite ich mit sessions. das hat den grossen vorteil, dass ich
nicht x variablen hinundher schieben muss sondern nur noch meine "$sid". das
script läuft in allen browsern ab version 4 incl netscape 6.

viel spass damit

bernd

<?php
session_start($sid);
include ("common.php");
include ("connect.php");
?>

<!doctype html public "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
  <title>Suchergebnisse</title>

<link rel="stylesheet" href="../../../style/anzeige.css" type="text/css">
  </head>
<body>

<?php
session_register("versart");
session_register("fam");
session_register("bindung");
session_register("sb");
session_register("order");
session_register("test");
$q = "Leider k&ouml;nnen wir f&uuml;r diese Anfragekombination keine
Ergebnisse liefern!<br>query = $query";
$u = "<a href=formular-js.php><span class=liste8>Zur&uuml;ck zur
Auswahl</span></a>";

include ("auswahl.php");

$limit=3; // rows to return

//function c($test)
// {
  $a = join("', '",$test);
  //return $a;
// }
$query = "select * from $table where name in ('".$a."') and $msb > 0 order
by name asc";


$numresults=_(at)_mysql_query("$query") or die ("$q <br> $u");


$numrows=mysql_num_rows($numresults);

// next determine if page has been passed to script, if not use 1
if (empty($page)) {
$page = 1;
}

$offset = $limit * ($page - 1);

// get results
$result=mysql_query ("$query limit $offset,$limit");
echo "<center>\n";
echo "<table border=0><tr><td align=center>\n";
echo "<span class=liste8>Ergebnisseiten:</span>";
if ($page > 1) { // bypass PREV link if offset is 0
$refpage = $page - 1;
echo "<a href=\"$PHP_SELF?sid=".$sid."&page=$regpage\"><span
class=liste8>Anfang</span></a>  ";
}

// calculate number of pages needing links
$numpages=intval($numrows/$limit);

// $numpages now contains int of pages needed unless there is a remainder
from division
if ($numrows % $limit) {
// has remainder so add one page
$numpages++;
}

for ($i = 1; $i <= $numpages; $i++)
    { // loop thru
      if($page != $i)
        {
          echo "<a href='$PHP_SELF?sid=".$sid."&page=$i'><span
class=liste10>";
        }
         print $i;
          if($page != $i)
            {
              echo "</span></a>";
            }
              echo " ";
    }

// check to see if last page
if ($page < $numpages) {
 //if Netscape < version 6 keinen weiter Button anbieten
// not last page so give next link
$refpage = $page + 1;
echo " &nbsp;<a href=\"$php_self?sid=".$sid."&page=$refpage\"><span
class=liste8>Weiter</span></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
}
echo"</td></tr></table>\n";
echo "</center>\n";
 echo "<div align=center>\n";
echo "<table border=0>\n";
echo "<tr>\n";
echo "<td valign=top>\n";

if ($row = mysql_fetch_array($result))
{

   echo "<table bgcolor=#f7a011  width=80 border=0 cellpadding=3
cellspacing=3>\n";

        echo "<tr>\n";
        echo "<td height=20>\n";
        echo "<span class=liste9fb>Name</span>";
        echo "</td>\n";
        echo "</tr>\n";

                echo "</tr>\n";
                echo "</table>\n";
                echo "</td>\n";

        /*----Ab hier erfolgt das Auslesen aus der Datenbank---*/

        do
          {
                echo "<td valign=top>\n";
                echo "</td>\n";
                echo "<td valign=top>\n";
                echo "<table bordercolorlight=#0080ff width=153 border=0
cellpadding=3 cellspacing=3>\n";

                /*---- Name----*/

                echo "<tr>\n";
                echo "<td align=center height=20 bgcolor=#f7a021><span
class=liste9f>".$row['name']."</span></td>\n";
                echo "</tr>\n";
                echo "<tr>\n";
                echo "<td><hr noshade size=1>\n";
                echo "</td>\n";
                echo "</tr>\n";
                echo "</table>\n";



          }
                while($row = mysql_fetch_array($result));

                echo "</td>\n";
                echo "</tr>\n";
                echo "</table>\n";
echo "</div>\n";
                // next we need to do the links to other results
                echo "<center>";
                echo "<br>";
                if ($page > 1)
                  { // bypass PREV link if offset is 0
                        $refpage = $page - 1;
                        echo "<a
href=\"$PHP_SELF?sid=".$sid."&page=$regpage\"><span
class=liste8>Anfang</span></a>  ";
                  }

                // calculate number of pages needing links
                $numpages=intval($numrows/$limit);

                // $numpages now contains int of pages needed unless there
is a remainder from division
                if ($numrows % $limit)
                  {
                        // has remainder so add one page
                        $numpages++;
                  }

                for ($i = 1; $i <= $numpages; $i++)
                  { // loop thru
                        if($page != $i)
                          {
                                echo "<a
href='$PHP_SELF?sid=".$sid."&page=$i'><span class=liste10>";
                          }
                        print $i;
                        if($page != $i)
                          {
                                echo "</span></a>";
                          }
                        echo " ";
                  }

                // check to see if last page
                if ($page < $numpages)
                   {
                         //if Netscape < version 6 keinen weiter Button
anbieten
                         // not last page so give next link
                        $refpage = $page + 1;
                        echo "&nbsp;<a
href=\"$php_self?sid=".$sid."&page=$refpage\"><span
class=liste8>Weiter</span></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                   }
                 echo ("</center>");

        }

        else
          {
                echo "<center>\n";
                echo "<table border=0 width=100% height=70%>\n";
                echo "<tr>\n";
                echo "<td>\n";
        echo "<p align=center>\n";
                echo "<span class=liste10fb>Es wurden leider keine
entsprechenden Daten gefunden!</span>\n";
                echo "</p>\n";
                echo "</td>\n";
                echo "</tr>\n";
                echo "</table>\n";
                echo "</center>\n";
          }

     ?>
</body>
</html>



---
Ausgehende Mail ist zertifiziert virenfrei.
Überprüft durch AVG Antivirus System (http://www.grisoft.com/de).
Version: 6.0.264 / Virendatenbank: 136 - Erstellungsdatum: 02.07.2001


_________________________________________________________
Do You Yahoo!?
Get your free _(at)_yahoo.com address at http://mail.yahoo.com



php::bar PHP Wiki   -   Listenarchive