Results 1 to 2 of 2

Thread: two values in a row

  1. #1
    Join Date
    Aug 2009
    Posts
    74
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default two values in a row

    Hi All,

    Iam geting values from mysql database and i want to show them side by side (for example, iam getting the 10 movies list, i can show them one by one) Now What exactly i need is, if i can get first two values in frirst row and in next row next two values and that goes on.

    <? PHP
    echo "
    <table align=center border=1>
    <tr><td>
    $movie </td></tr></table>";

    ?>

    For this i will get

    Trainer
    The Pianist
    Titanic
    Lagaan
    The Reader
    Rocky 1
    Rocky 2
    Rocky3

    Now what i need is

    Trainer The Pianist
    Titanic Lagaan
    The Reader Rocky 1
    Rocky 2 Rocky3


    I dont no, if it is the right place or not, but of any one knows how to do it plzzzzzz hlp me

  2. #2
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    This confused me for a while too until I stumbled upon this and it became very easy. Now this is straight from my code so you'll have to adapt it to your needs but you'll understand the layout as to how to make it work from this.
    PHP Code:
    $column 4;
    $rowend 1;
    echo 
    "<table cellspacing=\"6px\" style=\"width:100%\"><tr>";
    $get_brands mysql_query("SELECT * FROM brands WHERE active='1' AND is_atv='0' ORDER BY brand ASC");
    while (
    $the_brands mysql_fetch_array($get_brands))
    {
        
    $b_id $the_brands['id'];
        
    $b_name $the_brands['brand'];
        
    $b_img $the_brands['brand_logo'];
        
    echo 
    "<td><a href=\"wheels.php?brand=$b_id\"><img src=\"$b_img\" alt=\"$b_name\"/></a></td>";
    if (
    $rowend == $column){ echo "</tr><tr>"$rowend=0;}
    $rowend++;
    }
    echo 
    "</tr></table>"

Bookmarks

Posting Permissions

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