2016-03-31 5 views
0

私は、Artistテーブルからすべてのデータを出力し、確立されたテーブルに出力する非常に簡単なクエリを書きました。私はデータベースを二重チェックして、すべてのスペルは正しいですが、何らかの理由で何らかのデータが出力されていません。MySQL Artistテーブルのデータをすべて出力しないのはなぜですか?

コネクタコード

<?php 

$conn = mysqli_connect("localhost", "b4014107", "Windows1", "b4014107_db2") or die (mysqli_connect_error()); 

?> 

メインコード

!DOCTYPE HTML> 
<html> 
<head> 
<title>View Artist Table</title> 
</head> 
<body> 

<?php 
//Includes speicifed details in order to connect to MySQL 
include('ConnectorCode.php'); 

//mysql_query command is used to select data from Artist table 
$result = mysqli_query("SELECT * FROM tbl_Artist"); 

echo "<table border='1'>"; 
echo "<tr> <th>Artist ID</th> <th>Artist Name</th> </tr>"; 

//Results are looped and then displayed in tables 
while($row = mysqli_fetch_array($result)) { 
echo "<tr>"; 
echo "<td>" . $row ['Artist_id'] . "</td>"; 
echo "<td>" . $row ['Artist_Name'] . "</td>"; 
echo "</tr>"; 
} 

echo "</table>"; 

//Connection is closed 
     mysqli_close($conn); 


?> 

<p><a href="ArtistNew.php">Add a new Artist</a></p> 
<p><a href="ArtistEdit.php">Edit a current Artist</a></p> 
</body> 
</html> 

私が間違って何をしているのですか?

+1

「error_reporting(E_ALL)」をオンにします。あなたは警告を受け取りますか? – Barmar

+0

データなしでコネクタファイルを提供してください。 –

+0

申し訳ありません、コネクターファイルをページに追加しました。 –

答えて

0

私はこれがあなたの問題だと思う:

用途:$result->fetch_assoc()

の代わりに:mysqli_fetch_array($result)

0

私は解決策を見つけました! mysqli_queryの中に$ connを追加するだけです。

$result = mysqli_query($conn, "SELECT * FROM tbl_Artist"); 
関連する問題