新手试图显示MySQL数据

时间:2013-03-03 16:06:29

标签: php mysql

我是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以显示全名?

谢谢!

1 个答案:

答案 0 :(得分:0)

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

$modTitle = $tmpl['txtFirstName'].' '.$tmpl['txtLastName'];