Jump to content

Post link based on column name, with space between words


strago

Recommended Posts

Original code.

 

 

$row = mysql_fetch_assoc ($result);
echo "<TABLE border=1>\n";
echo "<TR>\n";
foreach ($row as $heading=>$column)
{
    echo "<TD><b><a href={$_SERVER['PHP_SELF']}?order=$heading>$heading</a></b></TD>";
}
echo "</TR>\n";

 

How do I make the code below show the column names with a space between the words?

 

$row = mysql_fetch_assoc ($result);
echo "<TABLE border=1>\n";
echo "<TR>\n";
foreach ($row as $heading=>$column)
if($column == 'ColumnOne')
{
    echo "<TD><b><a href={$_SERVER['PHP_SELF']}?order=$heading>Column One</a></b></TD>";
}
if($column == 'AnotherColumn')
{
    echo "<TD><b><a href={$_SERVER['PHP_SELF']}?order=$heading>Another Column</a></b></TD>";
}
else
 {
    echo "<TD><b><a href={$_SERVER['PHP_SELF']}?order=$heading>$heading</a></b></TD>";
}
echo "</TR>\n";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.