Custom Search

News World

May 16, 2011

Showing Data Table Per Page With PHP Script

1. < ? php
2. // STEP 1. CREATE DATABASE
3. // --------------------------------------------------------------------------------
4. // create database : eod
5. // create table : tbproduk
6. // create field on table tbproduk :
7. // idp kprod nprod hprod sprod gprod tprod pstatus pview pstock
8. // --------------------------------------------------------------------------------
9. // STEP 2. ACTIVATE OF DATABASE
10. // --------------------------------------------------------------------------------
11. $db_hname = "localhost";
12. $db_uname = "root";
13. $db_pword = "";
14. $db_name = "eod";
15. $link = mysql_connect($db_hname, $db_uname, $db_pword) or die("Not Success ....!");
16. if (!$link) { die('Could not connect: ' . mysql_error()); }
17. mysql_select_db($db_name);
18.
19. if($_GET['rto']==''){
20. $rt = 1;
21. }else{
22. $rt = $_GET['rto'];
23. }
24.
25. $tb_produkm = mysql_query("SELECT * FROM tbproduk");
26. $rtb_produk = mysql_num_rows($tb_produkm);
27.
28. if($_GET['tp']==''){
29. $tp=1;
30. }else{
31. $tp=$_GET['tp'];
32. }
33. ? >
34.
35. Show Total Record Per Page :
36. [< a href ='?tp=1&rto=< ? php echo $_GET['rto']; ? >'>1< /a >]
37. [< a href ='?tp=3&rto=< ? php echo $_GET['rto']; ? >'>3< /a >]
38. [< a href ='?tp=5&rto=< ? php echo $_GET['rto']; ? >'>5< /a >]
39. [< a href ='?tp=10&rto=< ? php echo $_GET['rto']; ? >'>10< /a >]
40. [< a href ='?tp=< ? php echo $rtb_produk; ? >'>All< /a >]
41. < p >< p >
42.
43. < ? php
44. $tb_produk = mysql_query("SELECT * FROM tbproduk LIMIT ".$rt." ,".$tp);
45. echo '< p >Product Information< br >';
46. echo 'No/Product Name/ Product ID/ Total Stock/Product Price';
47. echo '< br >';
48. echo '---------------------------------------------------------------------------< br >';
49. $rtot = mysql_num_rows($tb_produk);
50. for($j=1;$j<=$rtot;$j++){
51. $k=$j-1;
52. $tbv_product = mysql_fetch_array($tb_produk);
53. echo 'Product : '.($k+$_GET['rto']).'/'.$tbv_product['nprod'].'/'.$tbv_product['kprod'].'/'.$tbv_product['pstock'].'/';
54. echo ' USD '.number_format($tbv_product['hprod'], 2, '.', ',').'< br >';
55. echo '---------------------------------------------------------------------------< br >< br >';
56. }
57. //----------------------------------------------------------
58. // Next Data and Previous Data Process
59. //----------------------------------------------------------
60. if ($_GET['rto']>1){
61. ? >
62. [< a href ='?rto=< ? php echo $rt-$tp;? >&tp=< ? php echo $_GET['tp']; ? >'>Previous Data< /a >]
63. < ? php
64. }else{
65. echo '[Previous Data]';
66. }
67.
68. if ($_GET['rto']< $rtb_produk-1){
69. ? >
70. ['>Next Data]
71. < ? php
72. }else{
73. echo '[Next Data]';
74. }
75. ? >
76.

1 comment:

Sankar said...

I have read your blog its very attractive and impressive. I like it your blog.

PHP 7 Training in chennai | PHP 7 Training Course

PHP 7 Training in chennai |
Online PHP 7 Course

IT Conversations

Moneycontrol Latest News

Latest new pages on Computer Hope

Latest from Infoworld

Door Lock

Door Lock Import Top Door Lock from China Contact Quality Manufacturers Now