ncurran217 Posted December 20, 2012 Share Posted December 20, 2012 I have this code and I have finally got the results in a select drop down box, but each row is in a separate drop down box, not it one with multiple ones. Here is my code: <h1>View Log</h1> <?php $timezone = "America/Chicago"; date_default_timezone_set($timezone); $today = date("m/d/Y"); ?> <form method="get" action="getlog.php"> <table width="1500" border="0"> <tr> <td>Forte ID:</td> <td> <?php $serverName2 = 'SRB-Nick_Desktop\SQLEXPRESS'; $connectionInfo2 = array('Database'=>'cslogs', 'UID'=>'cslogslogin', 'PWD'=>'123456'); $connection2 = sqlsrv_connect($serverName2, $connectionInfo2); $query2 = ' SELECT ForteID FROM Reps'; $result2 = sqlsrv_query($connection2,$query2); if (!$result2) { $message2 = 'ERROR: ' . sqlsrv_errors(); return $message2; } else { $i2 = 0; while ($i2 < sqlsrv_num_rows($result2)) { $meta2 = sqlsrv_fetch($result2, $i2); echo '' . $meta2->name . ''; $i2 = $i2 + 1; } while ( $row2 = sqlsrv_fetch_array( $result2, SQLSRV_FETCH_ASSOC )) { $count2 = count($row2); $y2 = 0; while ($y2 < $count2) { $c_row2 = current($row2); echo '<select name="test" id="test">'; echo '<option name="Forte_ID" id="Forte_ID" value="' .$c_row2. '";>' .$c_row2.'</option>'; next($row2); $y2 = $y2 + 1; } echo '</select>'; } sqlsrv_free_stmt ($result2); } sqlsrv_close( $connection2); ?> </td> </tr> <tr> <td>Start Date:</td> <td><input name="start_date" type="date" value="<?php echo $today;?>" autocomplete="off" required="required"></td> </tr> <tr> <td>End Date:</td> <td><input name="end_date" type="date" value="<?php echo $today;?>" autocomplete="off" required="required"></td> </tr> </table> <br> <input type="submit" name="getLog" value="Get Log"><br><br> <input type="button" value="Back to Form" onclick="window.location.href='index.php';"> <br> </form> Let me know if a picture of what it looks like would help! Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/272224-php-select-drop-down-box/ Share on other sites More sharing options...
NomadicJosh Posted December 20, 2012 Share Posted December 20, 2012 (edited) You will need to move <select name="test" id="test"> and </select> outside of your while loop. Edited December 20, 2012 by parkerj Quote Link to comment https://forums.phpfreaks.com/topic/272224-php-select-drop-down-box/#findComment-1400602 Share on other sites More sharing options...
ncurran217 Posted December 20, 2012 Author Share Posted December 20, 2012 Wow, I have been trying that except for the </select>. Thank you so much!!! Quote Link to comment https://forums.phpfreaks.com/topic/272224-php-select-drop-down-box/#findComment-1400603 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.