PHP,MySql添加表中数据的链接

时间:2015-04-06 04:05:34

标签: php mysql

我遇到的问题是当我添加链接时,链接不会显示。

这是我的代码

foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
     if ($k == "name") {   // name is table column
         $url = "<a href='http://127.0.0.1/People-Match/person.php'>".$v."</a>";
         echo $url;
     } else {
        echo $v;
     }
}

对于表格式,我使用下面的代码

echo "<table style='border: solid 1px black;'>";
echo "<tr><th>Id</th><th>Name</th><th>Sex</th><th>Phone</th><th>Email</th><th>Address</th><th>Birth Date</th><th>Place of Birth</th></tr>";

class TableRows extends RecursiveIteratorIterator {
     function __construct($it) {
         parent::__construct($it, self::LEAVES_ONLY);
     }

     function current() {
         return "<td style='width: 150px; border: 1px solid black;'>" . parent::current(). "</td>";
     }

     function beginChildren() {
         echo "<tr>";
     }

     function endChildren() {
         echo "</tr>" . "\n";
     }
}

0 个答案:

没有答案