Skip to content
Advertisement

populating my dropdown menu using procedural prepared statement

I would like to ask on how do I populate my dropdown/<select> via retrieving my data in MySQL database. I am using procedural prepared statement to add a security or avoid SQL injection.

Problem: It’s only retrieving one data from my database which is I do have a two data stored in my table and how do I insert it through my <option> tag? I’m currently doing right now is first retrieve all research_title.

index.php

JavaScript

includes_getOptionList.php

JavaScript

enter image description here

Advertisement

Answer

  • The </select> close tag should be outside the while loop.
  • You must not include PHP inside PHP (ex: echo '<?php ... ?>';).
  • You have an extra call (echo $title_research;).

Code:

JavaScript

Or:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement