View difference between Paste ID: vLxvwkkp and uvcqkyun
SHOW: | | - or go back to the newest paste.
1
<?php
2
class dbtable
3
{
4
5
function __construct()
6
{
7
//$this->dbhost = 'localhost';
8
//$this->dbuser = 'root';
9
//$this->dbname = 'iams';
10
//$this->dbpass = '';
11
//$this->dbusertable = 'users';
12
//session_start();
13
14
}
15
function passresult($result)
16
{
17
$this->result=$result;
18
$this->numofrow=mysql_num_rows($this->result);
19
$this->numofcol=mysql_num_fields($this->result);
20
}
21
function htmltable()
22
{
23
if (($this->numofrow)>0)
24
    {
25
    echo '<table border=1>';
26
    echo '<tr>';
27-
        foreach ($row1=mysql_fetch_assoc($this->result) as $key=>$value) 
27+
        for ($i = 0; $i < $this->numofcol; $i++)
28
        {
29-
            echo '<th>'.$key.'</th>';
29+
            echo '<th>'.mysql_field_name($this->result, $i).'</th>';
30
        }
31
    echo '</tr>';
32
    while($row=mysql_fetch_array($this->result))
33
    //for($j=0; $j<($this->numofrow); $j++)
34
    {   var_dump($row);
35
        echo '<tr>';
36
        for($i=0; $i<($this->numofcol); $i++)
37
        {
38
            echo '<td>'.$row[$i].'</td>';
39
        }
40
        echo '</tr>';
41
42
    }
43
    echo '</table>';
44
    }
45
else {echo "No Data is there in supplied argument";}
46
}
47
}
48
49
?>