...

View Full Version : Print Out Data in Columns



ajloun
01-26-2010, 06:42 AM
Hello..

This is Just Example .


$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 ..


<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.
http://img689.imageshack.us/img689/4940/columnm.png

Len Whistler
01-26-2010, 06:58 AM
Untested


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



----------

ajloun
01-26-2010, 07:47 AM
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

hgs
01-26-2010, 08:12 AM
Probably this ....==



if ($counter == 0) {



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum