matthew798 Posted September 24, 2008 Share Posted September 24, 2008 Hola boys! <form action="" method="POST"> <table width="100%" border="0"> <tr> <td> </td> <td> <span class="general">Subject: </span><input type="text" /> <span class="general"># Prefix: </span><input type="text" /> <span class="general">Room #: </span><input type="text" /> <span class="general">Teacher: </span><select name="teacher"> <?php $query = "SELECT name FROM teachers"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result) or die(mysql_error()); echo '<option value="'.$row['name'].'">'.$row['name'].'</option>'; ?> </select> </td> </tr> </table> </form> I only ever get one option in the drop down menu, and it's the first in the database. What am i doing wrong? Link to comment https://forums.phpfreaks.com/topic/125556-php-inside-a-form/ Share on other sites More sharing options...
JasonLewis Posted September 24, 2008 Share Posted September 24, 2008 You need to run a loop to extract all the rows. while($row = mysql_fetch_array($result)){ echo '<option value="'.$row['name'].'">'.$row['name'].'</option>'; } Link to comment https://forums.phpfreaks.com/topic/125556-php-inside-a-form/#findComment-649179 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.