我正處於截止日期,我不確定現在要做什麼。無論SQL是否正確,Echo都不能正常工作
我測試了我的SQL,它據說可以根據我的數據庫工作,但在我的回聲中不起作用。
我嘗試了幾乎所有我知道的事情,我無法讓我的「Pad」行回顯。
我在:
$c->albumoverzicht();
echo "<table color:gray border = '0'>
<tr>
<th>Albumnaam:</th>
<th>Foto:</th>
<th>Bekijk</th>
<th>Verwijder</th>
</tr>";
while($album = mysql_fetch_array($c->teruggeven2()))
{
$album2 = $album['Naam'];
$test = $album['Pad'];
echo "<tr>";
echo "<td> <div id='album' style='color:#FFD700' >"; echo $album2; echo "</div></td>";
echo "<td> <div id= 'image'>"; echo '<img border="1" src="' .$test.'" width="100px" height="100"></br>'; echo "</td></div>";
echo "<td>"; echo "<button id='button' onclick = 'displayimage()'>Bekijk</button>"; echo"</td>";
echo "<td>"; echo "<button id='button' >Verwijder</button>"; echo"</td>";
echo "</tr>";
}
echo "</table>";
我的功能:
function albumfotooverzicht()
{
$this->verbinding();
$this->opdracht = "SELECT * FROM fotoalbum RIGHT JOIN foto ON foto.album_id = fotoalbum.ID";
$this->opdrachtverwerk = mysql_query($this->opdracht);
}
function teruggeven3()
{
return $this->opdrachtverwerk;
}
這是我的照片表:
foto CREATE TABLE `foto` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`Naam` varchar(40) NOT NULL,
`Pad` varchar(255) NOT NULL,
`album_id` int(11) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=34 DEFAULT CHARSET=utf8
我fotoalbum表:
fotoalbum CREATE TABLE `fotoalbum` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`Naam` varchar(40) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8
您沒有使用'mysql_error()'捕獲錯誤,那應該是開始調試數據庫問題的地方。 http://php.net/mysql_error –
生成的HTML是什麼樣的?你也應該儘量避免使用'mysql_ *'命令。它們在大多數應用程序中被棄用和出現安全漏洞。我建議升級喲PDO –
首先'teruggeven2()!= teruggeven3()',並且編號函數是一個** BIG **符號,應用程序設計中有錯誤。但是,既然如此,如果'teruggeven3()'也不起作用,'var_dump($ album);'來檢查那裏是什麼。 – Wrikken