0
echo "<table border=\"1\" cellpadding=\"2\" cellspacing=\"0\">";
foreach($array as $key => $value){
echo "";
echo "<tr><td><a href=\"".$url1.$key."\"><ax>" . $value . "</ax></a></td><td>".$url1.$key."</td></tr>";
echo "<br>";
}
echo "</table>";

Why doesn't this display the table?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

2 Answers2

0

is that in HTML5?

cellpaddingand cellspacingare not supported in HTML5

Johannes
  • 64,305
  • 18
  • 73
  • 130
  • the `
    `tags are definitely redundant, also the empty echo before each `` is unnecessary/redundant. What happens if you delete those two lines? And what is the ``tag?
    – Johannes Dec 13 '15 at 02:22
  • ax tag is color:white;.. now it looks like that, but still not working: `echo ""; foreach($array as $key => $value){ echo ""; } echo "
    " . $value . "".$url1.$key."
    ";`
    –  Dec 13 '15 at 02:28
  • hmmm... Personally, I would replace the escaped double-quotes with (unescaped) single quotes, but that can't be the reason, I suppose. Check the contents of your $array and of the $url1 variable, otherwise I can't think of anything else – Johannes Dec 13 '15 at 02:41
  • the output is correct but it does not display the table. i don't know why. –  Dec 13 '15 at 02:55
  • You mean it displays the data, just not the table? Is there any CSS? – Johannes Dec 13 '15 at 04:08
  • Yes it displays the data but not the table. Yes there is CSS. –  Dec 13 '15 at 10:45
0
<?php
    $array = array(
        "key1" => "value1",
        "key2" => "value2",
        "key3" => "value3",
    );

    echo '<table border="1" cellpadding="2" cellspacing="0">';
    foreach($array as $key=>$value) {
        echo('<tr><td>'.$key.'</td><td>'.$value.'</td></tr>');
    }
    echo '</table>';
?>

Works fine with a correctly constructed array.

Santy
  • 387
  • 2
  • 7