static dynamic?????

Discussion in 'PHP' started by computerzworld, May 25, 2007.

  1. #1
    Hi. I have made one table in PHP which is having dynamic header and dynamic data. Now I want to add a new column in it which is having static header. How can I add it? Please help me. Thanks in advance.
     
    computerzworld, May 25, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Post your code and explain exactly what you're trying to do.
     
    nico_swd, May 25, 2007 IP
  3. tinkerbox

    tinkerbox Peon

    Messages:
    55
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah, how to help if we dont even know how it is.
    Post code is better than long explaination!
     
    tinkerbox, May 25, 2007 IP
  4. computerzworld

    computerzworld Active Member

    Messages:
    214
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #4
    here is the code.........

    <?php
    $uname=$_SESSION['uname'];
    $pass=$_SESSION['password'];
    $tblname=$_GET['name'];
    $_SESSION['tbl']=$tblname;

    $dbname=$_GET['db'];
    define( 'NL', "\n" );
    define( 'TB', ' ' );
    $conn = mysql_connect( 'localhost',$uname ,$pass) or die( mysql_errno().': '.mysql_error().NL );
    $db=mysql_select_db($dbname,$conn) or die("Could not connect to database");
    $res1 = mysql_query("SHOW COLUMNS FROM $tblname");
    $cntfield=mysql_num_rows($res1);
    $res=mysql_query("select * from $tblname ");
    $cnt=mysql_num_fields($res);
    echo "<table border=1>";
    while($arr=mysql_fetch_array($res))
    {

    echo "<tr>";
    while ($row = mysql_fetch_array($res1))
    {

    echo "<td class=footer>";
    echo "<b>";

    print_r($row[0]);

    echo "</b>";

    echo "</td>";
    }

    echo "</tr>";

    echo "<tr>";

    for($i=0;$i<$cnt;$i++)
    {
    echo "<td>";
    echo $arr[$i];
    echo "</td>";
    }

    echo "</tr>";
    }

    echo "</table>";

    ?>
     
    computerzworld, May 25, 2007 IP
  5. raredev

    raredev Peon

    Messages:
    49
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    not sure if this is what you're asking. just add another <td></td>

    
    <?php
    $uname=$_SESSION['uname'];
    $pass=$_SESSION['password'];
    $tblname=$_GET['name'];
    $_SESSION['tbl']=$tblname;
    
    $dbname=$_GET['db'];
    define( 'NL', "\n" );
    define( 'TB', ' ' );
    $conn = mysql_connect( 'localhost',$uname ,$pass) or die( mysql_errno().': '.mysql_error().NL );
    $db=mysql_select_db($dbname,$conn) or die("Could not connect to database");
    $res1 = mysql_query("SHOW COLUMNS FROM $tblname");
    $cntfield=mysql_num_rows($res1);
    $res=mysql_query("select * from $tblname ");
    $cnt=mysql_num_fields($res);
    echo "<table border=1>";
    while($arr=mysql_fetch_array($res))
    {
    
    echo "<tr>";
    while ($row = mysql_fetch_array($res1))
    {
    echo "<td class=footer>";
    echo "<b>";
    print_r($row[0]);
    echo "</b>";
    echo "</td>";
    }
    echo "<td>static title</td>";
    echo "</tr>";
    
    echo "<tr>";
    for($i=0;$i<$cnt;$i++)
    {
    echo "<td>";
    echo $arr[$i];
    echo "</td>";
    }
    echo "<td>static content</td>";
    echo "</tr>";
    }
    
    echo "</table>";
    
    ?>
    
    PHP:
     
    raredev, May 25, 2007 IP
  6. computerzworld

    computerzworld Active Member

    Messages:
    214
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #6
    i have tried this but it is coming in table data instead what i want is it in table header. how can i do this?
     
    computerzworld, May 25, 2007 IP
  7. raredev

    raredev Peon

    Messages:
    49
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    how bout replacing this

    
    echo "<td>static title</td>";
    
    PHP:
    with this:
    
    echo "<td class=footer><b>static title</b></td>";
    
    PHP:
    :D
     
    raredev, May 25, 2007 IP
  8. computerzworld

    computerzworld Active Member

    Messages:
    214
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #8
    it is giving the same result.........
     
    computerzworld, May 25, 2007 IP