On Feb 3, 2007, at 10:04 PM, Paul Novitski wrote:


On Feb 3, 2007, at 9:09 PM, Albert Padley wrote:
I have an echo statement that I use in conjunction with a MySQL query.

echo "<tr>\n<td class=\"tabletext\">" . $row['time'] . "</td>\n<td
class=\"tabletext\">" . $row['field'] . "</td>\n<td class= \"tabletext\">" . $row['division'] . "</td>\n";

This works perfectly fine. However, I will be using the same code
numerous times on the page and wanted to stuff it all into a
variable. At this point I can't remember the proper syntax and
quoting to get this right. Any takers?


At 2/3/2007 08:09 PM, Christopher Weldon wrote:
You could always make it a function...ie:

function drawTableRow($sqlRow) {
return "<tr>\n<td class=\"tabletext\">". $sqlRow['time'] ."</ td> \n<td class=\"tabletext\">".$row['field']."</td>"; // Simplified for
time purposes.
}

Good suggestion.  I like heredoc's clean presentation:
__________________________________

function drawTableRow($sqlrow)
{
    return <<<_
<tr>
        <td class="tabletext">{$sqlrow['time']}</td>
        <td class="tabletext">{$sqlrow['field']}</td>
        <td class="tabletext">{$sqlrow['division']}</td>
</tr>

_;
}
__________________________________

By the way, if every cell in every row is class "tabletext" why have a class at all? You could simply apply the desired styles to the td element.

Regards,

Paul
I'm using heredoc elsewhere on the page so that's a good idea.

As far as the CSS on the <td>, other cells in the table have different styling.

Al

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to