Re: Stuffing code into variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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.php



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.
}

// 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@xxxxxxxxxxxxxxxxxx
(866) 813-4603 x605

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux