php - populate drop down list from database using mysqli prepared statements -
as title says want generated data database , show in dropdown. made code , doesn't show error thing echos code in dropdown. works when echo it. , 1 more thing doesn't show distinct results.
here code:
<html> <head> <title>filter</title> </head> <body> <?php include 'conn.php';?> <?php $stmt = $con->prepare("select distinct author, book_name, language bk_tst_fltr "); $stmt->execute(); $stmt->bind_result($author,$book_name,$language); $stmt->store_result(); echo "<select name='book'>"; while($row=$stmt->fetch()){?> <p><?php echo '<option value="$row["author"]">"$row["author"]"</option>'; ?></p> <?php } echo "</select>"; ?> </body> </html>
is shows $row["author"]
in dropdown.
can solve problem???
thank you.
my database
id author book_name language price 1 kishore 1 english 500 2 kumar 2 english 600 3 kishore 3 german 700
you should use double quotes variable expanding, or exit string , concat normally.
also, change while($stmt->fetch()){?>
echo '<option value="'.$author.'">"'.$author.'"</option>';
try using query instead:
"select author, book_name, language bk_tst_fltr group author"
Comments
Post a Comment