1

我是 PHP 新手,所以请耐心等待。:)

我正在尝试编辑一个编辑用户个人资料的代码块。标题是一般的“编辑”标题,但我想将其换掉并显示正在编辑个人资料的人的名字和姓氏。

PHP的块:

 $modTitle = MSG_EDIT;
        $modHeader = '<a href="index.php?module=administration">'. MSG_ADMINISTRATION . '</a> &gt; <strong>' . MSG_EDIT . '</strong>';

        $SQL = sprintf(SQL_GET_USER, $id);
        $RS =& new DBRecordset();
        $RS->Open($SQL, $this->DB);
        if (!$RS->EOF()) {
            $tmpl['txtUsername'] = htmlspecialchars($RS->Field('Username'));
            $tmpl['txtFirstName'] = htmlspecialchars($RS->Field('FirstName'));
            $tmpl['txtLastName'] = htmlspecialchars($RS->Field('LastName'));
            $tmpl['txtAddress1'] = htmlspecialchars($RS->Field('Address1'));
            $tmpl['txtAddress2'] = htmlspecialchars($RS->Field('Address2'));
            $tmpl['txtCity'] = htmlspecialchars($RS->Field('City'));
            $tmpl['txtState'] = htmlspecialchars($RS->Field('State'));
            $tmpl['txtCountry'] = htmlspecialchars($RS->Field('Country'));
            $tmpl['txtPostcode'] = htmlspecialchars($RS->Field('Postcode'));
            $tmpl['txtPhone1'] = htmlspecialchars($RS->Field('Phone1'));
            $tmpl['txtPhone2'] = htmlspecialchars($RS->Field('Phone2'));
            $tmpl['txtPhone3'] = htmlspecialchars($RS->Field('Phone3'));
            $tmpl['txtEmail'] = htmlspecialchars($RS->Field('EmailAddress'));
            $tmpl['Userlist'] = '';
        }
        $RS->Close();
        unset($RS);
    }

    $this->setHeader($modTitle);
    $this->setModule($modHeader);
    $this->setTemplate('user_form', $tmpl);
    $this->Render();
// }}}
}

$modTitle 是显示的通用标题,所有 MSG_ 引用都从外部文件中提取静态文本。

如何更改 $modTitle 以显示全名?

谢谢!

4

1 回答 1

0

更改if (!$RS->EOF()) {块(在}右括号之前),添加以下行:

$modTitle = $tmpl['txtFirstName'].' '.$tmpl['txtLastName'];
于 2013-03-03T16:09:49.097 回答