我在admindashboardview.class.php 加了紅字的內容...
function _loadViewData()
{
// for each blog, load some statistics
$articles = new Articles();
$comments = new ArticleComments();
$trackbacks = new Trackbacks();
$resources = new GalleryResources();
$recentPosts = Array();
$recentComments = Array();
$recentResources = Array();
//-------------------------------------------------------------------------------------------
$mining = Array();
$mining = $this->_loadMiningResults( $this->_userInfo->getUsername()); //-------------------------------------------------------------------------------------------
// load some statistics for each one of the blogs
foreach( $this->_userBlogs as $userBlog ) {
$recentPosts[$userBlog->getId()] = $articles->getBlogArticles( $userBlog->getId(),
-1,
DASHBOARD_MAX_RECENT_ITEMS,
0,
POST_STATUS_PUBLISHED );
$recentComments[$userBlog->getId()] = $comments->getBlogComments ( $userBlog->getId(), DASHBOARD_MAX_RECENT_ITEMS );
$recentTrackbacks[$userBlog->getId()] = $trackbacks->getBlogTrackbacks( $userBlog->getId(), DASHBOARD_MAX_RECENT_ITEMS );
}
$this->_params->setValue( "userblogs", $this->_userBlogs );
$this->_params->setValue( "recentposts", $recentPosts );
$this->_params->setValue( "recentcomments", $recentComments );
$this->_params->setValue( "recenttrackbacks", $recentTrackbacks );
//----------------------------------------------------------------------------------------------
$this->_params->setValue( "mining", $mining ); //----------------------------------------------------------------------------------------------
}
還有這個Model
//---------------------------------------------------------------------------
function _loadMiningResults( $userId )
{
$lnk = mysql_connect('localhost','帳號','密碼') or die("無法連線到該資料庫");
mysql_select_db('lifetype',$lnk)or die("無法連線到該資料庫");
//echo $id;
$sql = "select MARC_ID FROM history WHERE (ID = '$userId')";
$result = mysql_query($sql);
//echo $sql;
while ($row = mysql_fetch_object($result))
{
$MARC_ID=$row->MARC_ID;
$sql1 = "select MARC_ID1 FROM mining WHERE (MARC_ID = ".$MARC_ID.")";
$result1 = mysql_query($sql1);
//echo $sql1;
while ($row = mysql_fetch_object($result1))
{
$MARC_ID1=$row->MARC_ID1;
//echo $MARC_ID1;
sybase_min_server_severity(11);
$conn = sybase_connect("NCTU-T22", "帳號", "密碼") or die("Could not connect !");
//echo $conn;
sybase_select_db("totals2",$conn);
$sql2 = "select * FROM Mar3100 WHERE (MARC_ID = ".$MARC_ID1.")";
$result2 = sybase_query($sql2);
//echo $sql2;
while($row = sybase_fetch_assoc($result2))
{
$MARC_ID1 = $row["MARC_ID"];
$title2 = $row["TITLE"];
//echo $title2;
return $title2;
/*if ( $MARC_ID1 <> "" ){
echo "<p><a href='
http://XXX.XXX.XXX.XXX/book/check.php?id=".$MARC_ID1."&T=0&ty=ie'>$title2</a></p>";
}*/
}
}
}
/*if ($MARC_ID1 == ""){
echo "無推薦書籍";
}*/
在dashboard.template裡面加了這一段
{foreach from=$mining item=mining}
<tr style="background-color: {cycle values="#FFFFFF,#F7F7F7"};">
<td>
<a target="_blank" href="">{$mining}</a><br/>
</td>
</tr>
{/foreach}
發生了一個問題...
在程式裡面 ehco出的資料筆數是對的(三筆) 可是只要用return 筆數就會只剩第一筆...
可是不return 就一筆資料也沒有... @@
是return的用法錯了嗎? 還是應該要用別的呢?
return array也是一樣 >"<
謝謝Mark熱心幫忙 感激不盡...