News World
May 19, 2011
Create a Simple View Table List Data with PHP Script
1
2
3 --------------------------------------------------
4 Create file flds.php in to "natures" folder
5 --------------------------------------------------
6
7
8 copy the script below to flds.php
9 --------------------------------------------------
10
11
12 < ? php
13 $db_hname = "localhost";
14 $db_uname = "root";
15 $db_pword = "";
16 $db_name = "eod";
17 $link = mysql_connect($db_hname, $db_uname, $db_pword) or die("Not Success ....!");
18 if (!$link) { die('Could not connect: ' . mysql_error()); }
19 mysql_select_db($db_name);
20 $ltable = mysql_list_tables($db_name);
21 ? >
22 < table width=100% cellpadding=5 cellspacing=0 border=0 height=100% >
23 < tr >
24 < td style='border-right: 1px;border-right-color: #003366;border-right-style: solid;width: 200px;vertical-align:top;' >
< b >TABLE LIST< /b > : < p >< br >
25
26 < ? php
27 for ($i = 0; $i < mysql_num_rows($ltable); $i++){
28 ? >
29 < a href='fld.php?tbls=< ? php echo mysql_tablename($ltable, $i);?>'>< ? php echo mysql_tablename($ltable, $i).'< p >';? >< /a >
30 < ?php
31 }
32 ?>
33 < /td >
34 < td style='vertical-align:top;font-family:arial verdana;font-size:12px;'>
35 Table Name : < b >< ? php echo $_GET['tbls'];?>< /b >< p >< hr >
36 < table border=0 cellpadding=0 cellspacing=0 width=675 >
37 < tr >
38 < td style='vertical-align:top;font-family:arial verdana;font-size:12px;width=75px;text-align:right;padding-right:10px' >#Field< /td >
39 < td style='vertical-align:top;font-family:arial verdana;font-size:12px;width=200px'>Field Name< /td >
40 < td style='vertical-align:top;font-family:arial verdana;font-size:12px;width=150px'>Field Type< /td >
41 < td style='vertical-align:top;font-family:arial verdana;font-size:12px;width=150px'>Field Flags< /td >
42 < td style='vertical-align:top;font-family:arial verdana;font-size:12px;width=100px'>Field Len< /td >
43 < /tr >
44 < ? php
45 $res = mysql_query("select * from ".$_GET['tbls'], $link);
46 $nfld = mysql_num_fields ($res);
47 echo 'Total field : '.$nfld.'< p >< hr >';
48 for ($j=0;$j< = $nfld-1;$j++){
49 ?>
50 < tr >
51 < td style='vertical-align:top;font-family:arial verdana;font-size:12px;width=75px;text-align:right;padding-right:10px'>< ? php echo $j+1;?>< /td >
52 < td style='vertical-align:top;font-family:arial verdana;font-size:12px;width=200px'>< ? php echo mysql_field_name($res, $j);?>< /td >
53 < td style='vertical-align:top;font-family:arial verdana;font-size:12px;width=150px'>< ? php echo mysql_field_type($res, $j);?>< /td >
54 < td style='vertical-align:top;font-family:arial verdana;font-size:12px;width=150px'>< ? php echo mysql_field_flags($res, $j);?>< /td >
55 < td style='vertical-align:top;font-family:arial verdana;font-size:12px;width=100px'>< ? php echo mysql_field_len($res, $j);?>< /td >
56 < /tr >
57 < ? php
58 }
59 ?>
60 < /table >
61 < hr >
62
63 < table border=0 cellpadding=0 cellspacing=0 width=100% >
64 < tr >
65 < ? php
66 for ($k=0;$k< = $nfld-1;$k++){
67 ?>
68 < td style ='background-color: #E8E8E8;border-right:1;border-right-style:dotted;border-width:1px;padding-left:5px;
font-weight:bold;border-bottom:1px;border-bottom-width:1px;
border-bottom-style:dotted;'>
69 < ? php echo mysql_field_name($res, $k);?>< /td >
70 < ? php
71 $rw = mysql_num_rows($res);
72 }
73 ?>
74 < /tr >
75
76 < ? php
77 for($n=1;$n< = $rw;$n++){
78 $drw = mysql_fetch_array($res);
79
80 ?>
81 < tr >
82 < ? php
for ($p=0;$p< = $nfld-1;$p++){
83 ? >
84 < td style ='border-right:1;border-right-style:dotted;border-width:1px;padding-left:5px;border-bottom:1px;border-bottom-width:1px;
border-bottom-style:dotted;vertical-align:top;font-size:8pt;';>
85 < ? php echo $drw[mysql_field_name($res, $p)]; ?> & nbsp;< /td >
86 < ? php
87 }
88 ?>
89 < /tr >
90
91 < ? php
92
93 }
94 ?>
95
96 < /table >
97 < /td >
98 < /tr >
99 < /table >
Subscribe to:
Post Comments (Atom)
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
1 comment:
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
Post a Comment