display in column n rows
Moderator: General Moderators
display in column n rows
can you guys please provide me the code to display the numbers of items of a certain table in column and in rows in 4x3.. i mean in 4 column n 3 rows...?? please help me out...
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I am not sure if this is what you need but this functions displays an array of data in table form. You just tell it how many columns you wantCode: Select all
function arrayToTable($arr,$cols)
{
$arrcnt = count($arr);
if ($arrcnt==0) return '';
$rows = ceil($arrcnt/$cols);
$tableArr = array();
for($i=0;$i<( ($rows*$cols) - $arrcnt);$i++)
$tableArr[]=' ';
$tableArr=array_merge($arr, $tableArr);
$str = '';
$line = '';
$cnt=1;
foreach($tableArr as $cell)
{
$str .= "<td>$cell</td>";
if ($cnt++ == $cols)
{
$line .= "<tr>$str</tr>";
$str = '';
$cnt=1;
}
}
return '<table width="100%">' . $line . '</table>';
}
$arr = array(4,5,6,7,7,87,"HELLO","BLLLA");
arrayToTable($arr,3);feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]solution
Hi
Thanks for the responses.
The problem is solved.
I removed the explicitly set the table height.
This prevents the rows from filling
the available height.
Thanks for the responses.
The problem is solved.
I removed the explicitly set the table height.
This prevents the rows from filling
the available height.
Code: Select all
<?php
echo "<table width=\"100%\" border=\"0\">";
echo"<tr align=\"center\" bgcolor=\"#FFFFFF\">";
echo" <td width=\"100%\" >
<div id=\"Layer2\" style=\"position:absolute; width:100%; height:100px; z-index:2; left: 8px; top: 310px;\">
<div id=\"scroll-box2\" style=\"overflow: auto; float: left; width: 100%; height: 240px; margin: 5px; \">\n";
//table begins
echo "<table width=\"98%\" height=\"\" left =\"4\" border=\"0\" font face =\"arial\">\n";
?>- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
As I said, take a look at the first two threads linked from Useful Posts.
