mysql - Variables not being printed from php while loop -
i have dropdown menu in html form calls php file included below , getting while loop , judging echoes seems executing correctly isn't returning info.
to start need book column listed , can increase complexity once can this. end goal have book, author, genre , email listed.
the table has format: id-book-author-genre-email
here php code:
include('definitions.php'); $con=mysqli_connect(db_host,db_user,db_pass,db_name); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); } $namequery="select book,author,genre,email book book = ?"; $namestmt = mysqli_prepare($con, $namequery); mysqli_stmt_bind_param($namestmt, "s", $_post['select1']); var_dump($_post); mysqli_stmt_execute($namestmt); /* bind variables 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 far while loop"; } /* close statement */ mysqli_stmt_close($namestmt); /* close connection */ mysqli_close($con); ?>
this returns: array(1) { ["select1"]=> &string(4) "book" } (,) book author genre email got far while loop (,) book author genre email got far while loop (,) book author genre email got far while loop
any suggestions i'm going wrong?
you not bind result variable. take @ http://php.net/manual/en/mysqli-stmt.fetch.php
Comments
Post a Comment