sorry but i am new here and i don't know php very well. I would like to ask how can i generate dynamic textboxes and labels depend on the selection on a popup menu. I want to make a site in wordpress that would have a popup menu that shows titles of the Thesis. I have a database with an array named wp_courses and there are course_id, Thesis_ID, course_title in it ,and an other array named Thesis with Thesis_ID,Thesis_Title.i want when a thesis is chosen to generate textboxes with the specific courses that the thesis have and labels with the title of the courses, to fill. I am confused how can i pass my database in the function.Can i do it with javascript?
//my php code so far
function showTextboxes(choise){
for(i=0;i<=choise;i++)
{
my_div.innerHTML = my_div.innerHTML +"<br>
<input type='text' name='mytext'+ i>";
}
$conn = mysqli_connect("localhost","root","","wordpress");
mysqli_query($conn,'SET NAMES utf8');
<label class='formLabel'>Title of thesis*</label><br />";
$query = "SELECT * FROM wp_thesis";
$result = mysqli_query($conn,$query);
echo"<select name='ThesisTitle' id='link_block' onChange='showTextboxes(this.selectedIndex);' required=''>
<option disabled='disabled' selected='selected' value=''></option>";
foreach ($result as $row)
{
echo "<option value= {$row[Thesis_ID]}> {$row[Thesis_Title]}</option>";
}
echo"</select><br />";
<div id="my_div"></div>