strago Posted May 10, 2013 Share Posted May 10, 2013 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"; Link to comment https://forums.phpfreaks.com/topic/277865-post-link-based-on-column-name-with-space-between-words/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.