Why isn't this pulling any data?
<?php
require_once('inc/dbc1.php');
$pdo = new PDO('mysql:host=###;dbname=#####', $username, $password);
$pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$sth = $pdo->prepare('
SELECT name
FROM Department
;');
$sth->execute(array(
$pID
));
?>
<div id="popup_name" class="popup_block">
<h2 style="padding:0; margin:0;">Add a:</h2><br>
<form action="inc/add_p_c_validate.php" method="post">
Professor<input type="radio" name="addType" value="Professor" />
Course<input type="ra开发者_C百科dio" name="addType" value="Course" />
<br><br>Name: <input type="text" name="name" /><br>
Department: <select id='deptName' name='deptName'>
<select name="deptName">
<?php
while($row = $sth->fetch(PDO::FETCH_ASSOC)) {echo "<option>".$row['name']."</option>";}
?>
</select>
It doesnt give any error, just doesnt show a dropdown with any 'option's in it. I've tried the query is phpmyadmin and it returns all the department names...
Output for Dropdown (nothing) :
Anyone?
Department: <select id='deptName' name='deptName'>
This first select, you didn't close it or provide any options. Delete this select first and the second select works.
精彩评论