0
本質上,我創建了一個有7種電影流派的電影訂購系統,並且我希望每個電影標籤都根據流派進行填充。此時我甚至不能讓桌子出現。誰能幫我嗎?使用MySql來使用特定列填充html表格
<div id="content">
<table>
<tr><th>Name</th> <th>Genre</th> <th>Year</th> <th>Rating</th></tr>
<?php
//connect to database
$dbc = mysql_connect('localhost' , 'username' , 'password');
$test = mysql_select_db('movies', $dbc);
if ($test = mysql_select_db('movies', $dbc))//test
{
$query = "SELECT * FROM 'movies' WHERE 'genre' = 'Action'";
//call query
$result = mysql_query($query, $dbc);
while ($row = mysql_fetch_array($result))
{
?>
<tr>
<td><?php print $row['name']; ?></td>
<td><?php print $row['genre']; ?></td>
<td><?php print $row['year']; ?></td>
<td><?php print $row['rating'];?></td>
</tr>
<table>
<?php
}//close the while loop
}//close the if statement
mysql_close($dbc);
?>
你可能得到一個MySQL錯誤。添加或死亡(mysql_error())到你的mysql語句的結尾,如下所示:$ result = mysql_query($ query,$ dbc)或die(mysql_error()); – Jade