Re: [SMARTY] table sections
| From: | Arleen Sales | Date: | Tue, 07 May 2002 18:22:28 +0000 |
| Subject: | Re: [SMARTY] table sections | ||
| References: | 1 2 3 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-4072@lists.php.net to get a copy of this message | ||
hi monte -
thanks for the reply. yes, each link would exist in its own cell. i haven't
tried versions of your example yet. i was able to get the result in php,
however, i'm transitioning the entire site to smarty but was unfamiliar with
producing the same result using smarty functions. don't know if this will
help and if it's overkill but here's a short? (shorter...) version of my
code:
<?php
require_once('prepend.php');
?>
<html>
<head>
<title>Untitled</title>
<style>
td { font-family: arial, verdana; font-size: 11px; }
a:link { text-decoration: none; }
</style>
</head>
<body>
<table width="90%" border="0" cellspacing="1"
cellpadding="3" align="center"
bgcolor="#CCCCCC">
<?php
$db = new db_oth;
$db->query("
SELECT article_categories.id, article_categories.label
FROM article_categories, articles
WHERE articles.cat_id = article_categories.id
AND articles.cat_id != '1'
AND articles.parent_id = '".$_REQUEST['pid']."'
AND FROM_UNIXTIME(articles.date) <= NOW()
GROUP BY articles.cat_id
ORDER BY article_categories.label ASC
");
while ($db->next_record())
{
$category_id[] = $db->f('id');
$category_label[] = stripslashes($db->f('label'));
}
$num_rows = $db->nf();
$l_column = ceil($num_rows/2);
$r_column = $num_rows-$l_column;
for ($i = 0; $i <= ($l_column - 1); $i++) {
echo '<tr bgcolor="#FFFFFF">';
echo '<td><a
href="'.$_SERVER['PHP_SELF'].'?display=titles&pid='.$_REQUEST['pid'].'&cid='
.$category_id[$i].'">'.$category_label[$i].'</a></td>';
if ($i < $r_column) {
echo '<td><a
href="'.$_SERVER['PHP_SELF'].'?display=titles&pid='.$_REQUEST['pid'].'&cid='
.$category_id[$i+$l_column].'">'.$category_label[$i+$l_column].'</a></td>';
} else {
echo '<td> </td>';
}
echo '</tr>';
}
?>
</table>
</body>
</html>
"Monte Ohrt" <monte@ispi.net> wrote in message
news:3CD7DCF9.9030803@ispi.net...
: There is an error in the below example, it should read:
:
: {math equation="ceil(total / cols)" cols=2 total=$var|@count
: assign="col_total"}
:
: where $var is the array of values being looped through.
:
: Monte
:
: Monte Ohrt wrote:
: > Do the links a,b,c need to be in separate table cells?
: >
: > If not, you could do it like this:
: >
: > {* figure out how many elements per column, assign to $col_total *}
: > {math equation="ceil(total / cols)" cols=2 total=$var
assign="col_total"}
: > <tr>
: > <td>
: > {section name=foo loop=$var}
: > $var[foo]<br>
: > {if not $smarty.section.foo.last and $smarty.section.foo.iteration
is
: > div by $col_total}
: > {* start next column *}
: > </td><td>
: > {/if}
: > {/section}
: > </td>
: > </tr>
: >
: > Arleen Sáles wrote:
: >
: >> i've done research and found similar examples and even a table
function
: >> provided peter bowyer, however, i'd like to achieve the result using
: >> sections.
: >>
: >> if a solution has already been posted to this question, could you
please
: >> direct me to it?
: >>
: >> i just want to display my links from a database query in table format
: >> this
: >> way:
: >>
: >> link a link d
: >> link b link e
: >> link c link f
: >>
: >> thank you in advance.
: >>
: >> arleen.
: >>
: >>
: >>
: >
: >
: >
:
:
:
: --
: Monte Ohrt <monte@ispi.net>
: Director of Technology, ispi Inc.
:
: