dtja73027 2013-08-29 17:11
浏览 11

PHP重复输出

I have a while loop fetching a row and I'm trying to create a structure so that each row will create 2 links. The first is a German word and the second being an English one. The output I'm getting is repeated as if the row isn't being incremented. I've narrowed it down to this:

PHP:

while ($row = $database->row()->fetch()) {
    foreach ($row as $value) {
        $this->data .= $value . "!";
    }
    list($this->pid, $this->german, $this->english) = explode("!", $this->data);
    $this->links .= "<a href=\"#\" class=\"german $this->pid\">$this->german</a><br/><a href=\"#\" class=\"english $this->pid\">$this->english</a><br/>";
}

Output:

die Männer
men
die Männer
men
  • 写回答

2条回答 默认 最新

  • douke7431 2013-08-29 17:34
    关注
        $row = array();
        while ($row = $database->row()->fetch()) {
            $row[] = $row;
        }
    
        foreach ($row as $value)
        {
            $this->data .= $value . "!";
            list($this->pid, $this->german, $this->english) = explode("!", $this->data);
            $this->links .= "<a href=\"#\" class=\"german $this->pid\">$this->german</a><br/><a href=\"#\" class=\"english $this->pid\">$this->english</a><br/>";
        }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000