PHP - Displaying MySQL Column Names and Values via PHP
$result = mysql_query($sql);
if ($result)
{
$total_row = mysql_num_rows($result);
}
if ($total_row > 0)
{
while ($tableRow = mysql_fetch_assoc($result)) {
$result_body.= "<item>";
foreach ($tableRow as $column => $value) {
$result_body.= "<{$column}><![CDATA[{$value}]]></{$column}>";
}
$result_body.= "</item>";
}
}
if ($result)
{
$total_row = mysql_num_rows($result);
}
if ($total_row > 0)
{
while ($tableRow = mysql_fetch_assoc($result)) {
$result_body.= "<item>";
foreach ($tableRow as $column => $value) {
$result_body.= "<{$column}><![CDATA[{$value}]]></{$column}>";
}
$result_body.= "</item>";
}
}