以下に含まれるphpファイルを呼び出すhtml形式のドロップダウンメニューがあり、whileループに到達し、エコーから判断すると、正しく実行されているように見えますが、情報が返されません。
まず、リストされている本の列が必要です。これができれば、複雑さを増すことができます。私の最終目標は、本、著者、ジャンル、メールをリストすることです。
テーブルの形式は次のとおりです。id-book-author-genre-email
これが私のPHPコードです:
include('definitions.php');
$con=mysqli_connect(DB_HOST,DB_USER,DB_PASS,DB_NAME);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$namequery="SELECT book,author,genre,email FROM book WHERE book = ?";
$namestmt = mysqli_prepare($con, $namequery);
mysqli_stmt_bind_param($namestmt, "s", $_POST['select1']);
var_dump($_POST);
mysqli_stmt_execute($namestmt);
/* bind variables to prepared statement */
mysqli_stmt_bind_result($namestmt, $name, $author, $genre, $email);
while(mysqli_stmt_fetch($namestmt))
{
printf("%s %s %s %s\n", $name, $author, $genre, $email);
echo "<br>";
echo "got as far as the while loop";
}
/* close statement */
mysqli_stmt_close($namestmt);
/* close connection */
mysqli_close($con);
?>
これは次を返します:array(1){["select1"] =>&string(4) "book"}(、)本の著者のジャンルの電子メールがwhileループまで取得されました(、)本の著者のジャンルの電子メールがwhileまで取得されましたループ(、)本の著者のジャンルの電子メールはwhileループまで取得されました
私が間違っているところに何か提案はありますか?