Re: Stuffing code into variable
| From: | Albert Padley | Date: | Sun, 04 Feb 2007 04:23:19 +0000 |
| Subject: | Re: Stuffing code into variable | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-248270@lists.php.net to get a copy of this message | ||
On Feb 3, 2007, at 9:09 PM, Christopher Weldon wrote:
On Feb 3, 2007, at 9:09 PM, Albert Padley wrote:Thanks. AlIt'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);} That's perfect. I should of thought of using a function.