NYCPHP Meetup

NYPHP.org

[nycphp-talk] print parsing confusion

David Mintz dmintz at davidmintz.org
Fri Apr 14 14:38:42 EDT 2006


On Fri, 14 Apr 2006, Brian Kaney wrote:

> And the markup is not really semanticly sound.  I hate mixing markup
> with code, but you may want to consider:
>
> while($row = mysql_fetch_array($category)) {
>      echo '<tr><td><label for="'
>          . htmlspecialchars($row['expenses_cat_number'])
>          . '">'
>          . htmlspecialchars($row['expenses_cat_desc'])
>          . '</label>'
>          . '</td><td><input type="text" name="expense_cat'
>          . htmlspecialchars($row['expenses_cat_number'])
>          . '" id="'
>          . htmlspecialchars($row['expenses_cat_number'])
>          . '" value="" /></td></tr>' . "\n";
> }
>
>
> Or even using a definition list, if you want to be super accessible:
>[...]


It's all an eyesore to me. Not to start a religious debate, but this is
almost an argument for things like Smarty

{section loop=$rows name=i}
<tr>
    <td>{$rows[i].expenses_cat_number|escape}</td>
    <td>{$rows[i].expenses_cat_desc|escape}</td>
    <!--  etc -->
</tr>
{/section}

or perhaps an argument for dropping into good old HTML mode interpersed
with the "friendly" PHP syntax

while($row = mysql_fetch_array($category)) : ?>
<tr>
  <td><?= htmlspecialchars($row['expenses_cat_number']?></td>
  <td><?= htmlspecialchars($row['expenses_cat_desc']?></td>
  <!--  etc -->
</tr>
<?php endwhile; ?>

---
David Mintz
http://davidmintz.org/

Amendment IV

The right of the people to be secure in their
persons, houses, papers, and effects, against
unreasonable searches and seizures, shall not be
violated, and no Warrants shall issue, but upon
probable cause, supported by Oath or affirmation,
and particularly describing the place to be
searched, and the persons or things to be seized.



More information about the talk mailing list