home *** CD-ROM | disk | FTP | other *** search
- DB-Browser
-
- This little handy code display the prev- and next-Button for Database-browsing. It shows the page where your are right now.
-
- <?
- /*
- Filename : demoBrowsDB.php3
- This Script can be used to browse a Database.
- the scipt contains prev- , Pages- and next- Button
- the only thing you have to do is :
-
- GetMaxRowsToShow = YOUR Select-statement
- needed to calculate the total number of Rows
- for example
- $GetMaxRowsToShow = "select count(*) as Anzahl from YOURTABLE where col1 = whatever"
-
- $GetRows = YOUR Select-statement
- The Rows you want to show
- for example
- GetRows = "select col1,col2 col3 from YOURTABLE where col1 = whatever limit $RL,$MaxRow "
-
- $RL = Starting with Row
-
- $MaxRow = number of Rows to display
-
- TIP : place the Script on your Webserver and let it run!
- Take care of the Parameter when you put it in your PHP-File!
-
- see it in action at http://www.it-development.de
- if you have an questions : Bernhard Bauder
- bbauder@it-development.de
- Have fun.
- Berni
- 28.03.2000
- */
-
- $MaxRow = 10;
-
- // is this the first time the Script is called?
- if (!isset($CR))
- {
- // $result = mysql_query($GetMaxRowsToShow ) or die ("Database error");
- // $row=mysql_fetch_array($result);
- // $CR= $row["Anzahl"];
- $CR=31; // delete this for your use
-
- $RL=0;
- }
-
-
-
-
- // get the Number of pages
- $AnzahlSeiten=intval($CR/$MaxRow);
- if ($AnzahlSeiten < ($CR/$MaxRow)){ $AnzahlSeiten++;}
-
-
-
-
-
-
- echo "<CENTER>";
- // prev Button
- if ($RL > 0) {
- $y=$RL-$MaxRow;
- // take care of your Parameter
- echo "[<a href=\"demoBrowsDB.php3?CR=$CR&RL=$y\"><<</a>] ";
- }
- // Pages
- for ($i = 1; $i <= $AnzahlSeiten; $i++)
- { $y=($i*$MaxRow)-$MaxRow;
- if ($y==$RL){echo "<B>";}
- // take care of your Parameter
- echo "[<a href=\"demoBrowsDB.php3?CR=$CR&RL=$y\">$i</a>] ";
- if ($y==$RL){echo "</B>";}
- }
- // next button
- if ($RL < ($CR-$MaxRow)) {
- $y=$RL+$MaxRow;
- // take care of your Parameter
- echo "[<a href=\"demoBrowsDB.php3?CR=$CR&RL=$y\">>></a>] ";
- }
- echo "</CENTER>";
- // now make a select with -> limit $RL,$MaxRow
-
- ?>
-
-