【发布时间】:2014-10-17 11:13:30
【问题描述】:
我开始一点一点地学习如何用 PHP 编程。但是我遇到了一个我自己无法解决的问题。所以我需要一点帮助。问题是,在我的函数中,我从数据库中获取信息。我想在下面发布的其他函数中使用变量 $DisplayProducts01Title
获取数据的函数:
//GetAllPages
function GetAllPages() {
$GetAllPagesSql = "SELECT ContentPages.ContentPagesID, ContentType.ContentTypeName, ContentInformation.ContentInformationTitle, ContentPages.ContentPagesOrder FROM `ContentPages` INNER JOIN ContentType ON ContentPages.ContentTypeID = ContentType.ContentTypeID INNER JOIN ContentInformation ON ContentPages.ContentInformationID = ContentInformation.ContentInformationID ORDER BY ContentPagesOrder";
$GetAllPagesQuery = mysql_query($GetAllPagesSql);
while (($GetAllPagesRow = \mysql_fetch_assoc($GetAllPagesQuery)) != false) {
if($GetAllPagesRow[ContentTypeName] == 'products01') {
DisplayProducts01DesignFunction();
$DisplayProducts01Title = $GetAllPagesRow[ContentTypeTitle];
return $DisplayProducts01Title;
}
else if ($GetAllPagesRow[ContentTypeName] == 'information01') {
DisplayInformation01DesignFunction();
}
}
}
显示数据的功能:
//DisplayProductsDesignFunction
function DisplayProducts01DesignFunction($DisplayProducts01Title) {
echo "<div class='paddingcnt' id='services'>
<div class='row-fluid'>
<div class='span12'>
<div class='pricing'>
<div class='container'>
<div class='row-fluid'>
<h1>" . $DisplayProducts01Title . "</h1>
<div class='row-fluid'>";
DisplayProducts01Function();
echo "</div>
</div>
</div>
</div>
</div>
</div>
</div>";
}
如何将函数 GetAllPages() 中的变量 $DisplayProducts01Title 用于函数 DisplayProducts01DesignFunction()?
提前致谢
【问题讨论】:
标签: php mysql if-statement while-loop