$db = new Database("localhost", "username", "password", "db");
$bodyHtml .= $db->GetMessage("HomePage");
$html = str_replace('$BODY_CONTENTS$', $bodyHtml, $html);
print $html;
“主页”是消息表中的字段
$db = new mysqli("localhost", "username", "password", "db");
$queryResult = $db->query("SELECT HomePage from messages");
if ($queryResult->num_rows = 1) { // assuming theres only one row
while ($row = $queryResult->fetch_assoc()) {
// concatenate to string
$bodyHtml .= $row['HomePage'];
}
}
// and your original code
$html = str_replace('$BODY_CONTENTS$', $bodyHtml, $html);
print $html;
可悲的是,我不想测试该代码,因为我不想为重新创建示例而烦恼。因此,我只能说理论上应该可行。