Re: Stuffing code into variable
| From: | Christopher Weldon | Date: | Sun, 04 Feb 2007 04:09:53 +0000 |
| Subject: | Re: Stuffing code into variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-248269@lists.php.net to get a copy of this message | ||
On Feb 3, 2007, at 9:09 PM, Albert Padley wrote:
It's late and I've been at this a long time today so I throw myself on the mercy of the list. 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? Thanks. Al Padley --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpYou 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.} // Execute the query foreach ($row = mysql_fetch_array($query)) {
echo drawTableRow($row);} /me pours you a cold frosty one to soothe the pain of the long struggle -- Christopher Weldon President & CEO Cerberus Interactive, Inc. cweldon@cerberusonline.com (866) 813-4603 x605