[FX.php List] Help needed to rewrite old FMP tags to PHP ( to achieve different table rows color )

Kevin Futter kfutter at sbc.melb.catholic.edu.au
Tue Mar 29 15:27:07 MST 2005

An even better approach would be for PHP to write class names into the HTML,
and then style them with CSS. CSS has tools that outdream anything that HTML
could ever do.

Eg: <tr <? if($i%2==1){echo "class=\"odd\"";}else{ echo "class=\"even\"";}

On 30/3/05 1:46 AM, "DC" <dan.cynosure at dbmscan.com> wrote:

> yes. it should work in principle, but there are grave limitations to
> this approach and there are errors in your foreach loop. it also looks
> like you can use short tags in your PHP installation (<??> as opposed to
> long tags <?php?>) Short tags are fine if your server supports them.
> the main problem is that your approach only gives you 10 rows! 2nd
> problem is your foreach has a table tag INSIDE the loop. CDML is such a
> limiting language that you have to realize that PHP has tools that
> outdream anything that CDML could ever do - so you have to reorganize
> your approach.
> try this instead (uses modulo operator to deal with odd/even):
> <table width="100%" border="0" cellpadding="2"cellspacing="0">
> <? $searchResult['data']=array(1,2,3,4,5); //dummy array ?>
> <? $i=1; ?>
> <? foreach($searchResult['data'] as $key=>$searchData){ ?>
>   <tr bgcolor="<? if($i%2==1){echo "#DDDDDD";}else{ echo "#AAAAAA";} ?>">
>    <td><? echo $value['recid'][0]; ?>
>    <td><? echo $searchData['recid'][0]; ?></td>
>    <td><? echo $searchData['Headline'][0]; ?></td>
>    <td><? echo $searchData['category'][0]; ?></td>
>   </tr>
> <? $i++; ?>
> <? } ?>
> </table>
> Another approach if you have not moved to FMP 7 yet is simply to call
> your CDML pages from PHP like this:
> <? file_get_contents("http://domain.com/old_fmp_cdml_query_here"); ?>
> You may have to tweak the CDML so that it doesn't return head or body
> tags but that lets you keep the CDML intact as you migrate to PHP.
> As you may know, FMP7 dropped support for CDML.
> HTH,
> dan

Kevin Futter
Webmaster, St. Bernard's College

More information about the FX.php_List mailing list