Log in

View Full Version : two values in a row



hemi
09-25-2010, 10:10 AM
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

fastsol1
09-25-2010, 02:19 PM
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.


$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>";