我會盡力解釋我的問題。 我有一個功能類,其中一個功能的目的是從數據庫中獲取信息並顯示它。 一切工作,因爲它應該,但現在我需要訪問一些變量,以在我的課堂外在另一個文件中使用它們,我不知道這應該怎麼做,所以我想知道如果有人可以指導我。在課堂以外訪問變量
function fetch(){
$this->_select_query = '
SELECT movies_id, movies_title, movies_director, movies_year, movies_category_id, cat.name
FROM movies
LEFT JOIN cat ON id = movies_category_id'
or die(mysqli_error());
$this->_stmt = $this->_mysqli->prepare($this->_select_query);
$this->_stmt->execute();
$this->_stmt->bind_result($this->_select_id, $this->_select_title, $this->_select_director, $this->_select_year, $this->_select_category_id, $this->_select_category_name);
$this->_stmt->store_result();
while($this->_stmt->fetch()){
echo '<tr>
<td>'.$this->_select_title.'</td>
<td>'.$this->_select_director.'</td>
<td>'.$this->_select_year.'</td>
<td>'.$this->_select_category_name.'</td>
<td><a href="index.php?form=edit&id='.$this->_select_id.'" title="Edit movie">Edit</a></td>
<td><a href="">Delete</a></td>
</tr>
';
}
}//close function fetch
功能獲取裏面是一類被稱爲電影,現在另一頁我有一個表格編輯(更新)這些電影上,我想回到標題,導演等。這種形式所以它裏面很容易注意到你正在改變。
現在我知道如何做到這一點使用PHP程序,但不是面向對象的PHP。 正如你也可以看到在這裏我回聲出整個表(該表的另一部分是一個向度頁) 所以因爲這個我不能用$影片 - >取()
我不希望有人可以給我一些關於我的問題的更多信息,因爲在這一點上我感覺有點失落,同時盯着相同的代碼,你會變得困惑和混淆東西。
親切的問候
編輯:我應該使用全局變量,常量?