You're here: Snippet Directory » PHP (128)
Language:

BrowsDB

Language: English
Programming Language: PHP
Published by: berni [not registered]
Last Update: 5/15/2006
Views: 1342


Description

This Script can be used to browse a Database. the scipt contains prev- , Pages- and next- Button

Code

1 <? 2 /* 3 Filename : demoBrowsDB.php3 4 This Script can be used to browse a Database. 5 the scipt contains prev- , Pages- and next- Button 6 the only thing you have to do is : 7 8 GetMaxRowsToShow = YOUR Select-statement 9 needed to calculate the total number of Rows 10 for example 11 $GetMaxRowsToShow = "select count(*) as Anzahl from YOURTABLE where col1 = whatever" 12 13 $GetRows = YOUR Select-statement 14 The Rows you want to show 15 for example 16 GetRows = "select col1,col2 col3 from YOURTABLE where col1 = whatever limit $RL,$MaxRow " 17 18 $RL = Starting with Row 19 20 $MaxRow = number of Rows to display 21 22 TIP : place the Script on your Webserver and let it run! 23 Take care of the Parameter when you put it in your PHP-File! 24 25 see it in action at http://www.it-development.de 26 if you have an questions : Bernhard Bauder 27 bbauder@it-development.de 28 Have fun. 29 Berni 30 28.03.2000 31 */ 32 33 $MaxRow = 10; 34 35 // is this the first time the Script is called? 36 if (!isset($CR)) 37 { 38 // $result = mysql_query($GetMaxRowsToShow ) or die ("Database error"); 39 // $row=mysql_fetch_array($result); 40 // $CR= $row["Anzahl"]; 41 $CR=31; // delete this for your use 42 43 $RL=0; 44 } 45 46 47 48 49 // get the Number of pages 50 $AnzahlSeiten=intval($CR/$MaxRow); 51 if ($AnzahlSeiten < ($CR/$MaxRow)){ $AnzahlSeiten++;} 52 53 54 55 56 57 58 echo "<CENTER>"; 59 // prev Button 60 if ($RL > 0) { 61 $y=$RL-$MaxRow; 62 // take care of your Parameter 63 echo "[<a href=\"demoBrowsDB.php3?CR=$CR&RL=$y\"><<</a>] "; 64 } 65 // Pages 66 for ($i = 1; $i <= $AnzahlSeiten; $i++) 67 { $y=($i*$MaxRow)-$MaxRow; 68 if ($y==$RL){echo "<B>";} 69 // take care of your Parameter 70 echo "[<a href=\"demoBrowsDB.php3?CR=$CR&RL=$y\">$i</a>] "; 71 if ($y==$RL){echo "</B>";} 72 } 73 // next button 74 if ($RL < ($CR-$MaxRow)) { 75 $y=$RL+$MaxRow; 76 // take care of your Parameter 77 echo "[<a href=\"demoBrowsDB.php3?CR=$CR&RL=$y\">>></a>] "; 78 } 79 echo "</CENTER>"; 80 // now make a select with -> limit $RL,$MaxRow 81 82 ?> 83

No comments avaiable

Add a comment

Name *  

Email (won't be displayed) *    

Website  

Comment *  

Sicherheitscode Security Code *    

RSS