Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts

    Print Out Data in Columns

    Hello..

    This is Just Example .

    PHP Code:
    $data mysql_query("SELECT * FROM test") or die(mysql_error());
    //Puts it into an array
    while($info mysql_fetch_array$data ))
    {
            
    $comment $info["comment"];
            
    $Tpl->assign('comment'$comment);

    I use Smarty .. that print the data in html template , i need to print the Data in columns instaed of row . each column has two rows ..

    PHP Code:
    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
      <
    tr>
        <
    td width="100%"><{comment}></td>
      </
    tr>
    </
    table
    any idea how to make the data prints out in columns like in the News Portals like this.

  • #2
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Untested

    PHP Code:
    echo "<table><tr>";
    $data mysql_query("SELECT * FROM test") or die(mysql_error());

    $counter 1;
    while(
    $info mysql_fetch_array$data )) {
    $counter $counter 2

    echo 
    "<td>$info["comment"]</td>";

    if (
    $counter 0) {
    echo 
    "</tr><tr>\n";
    }
    $counter++;
    }  

    echo 
    "</table>"


    ----------
    Leonard Whistler

  • #3
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts
    Thx.. But did not work

    i found this tutorial but to work with Array not Mysql , Could Someone Reedit the tutorial to work with mysql

    http://marislabs.org/node/6
    Last edited by ajloun; 01-26-2010 at 09:09 AM.

  • #4
    hgs
    hgs is offline
    New Coder
    Join Date
    Jan 2010
    Location
    Germany
    Posts
    83
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Probably this ....==

    PHP Code:
    if ($counter == 0) { 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •