here is the output in the loop of all the column values:

<?php $sql_s_core = "SELECT nameM FROM dbo.menu"; $result_core = sqlsrv_query($conn,$sql_s_core); while ($row_core = sqlsrv_fetch_array( $result_core,SQLSRV_FETCH_ASSOC)) echo '<option value="'. $row_core['nameM'] . '" name="'. $row_core['nameM'] . '">'; echo $row_core['nameM']; echo '</option>'; ?> 

but in the browser it is read like this: enter image description here

If you open the source, then everything is there:

 element for: <select id="m_elements"> <option>root element</option> <option value="TEST1" name="TEST1"><option value="TEST2" name="TEST2"><option value="TEST3" name="TEST3"><option value="TEST5" name="TEST5"><option value="TEST4" name="TEST4"><option value="TEST7!" name="TEST7!"><option value="PUNKT!!!!" name="PUNKT!!!!"><option value="PARENT" name="PARENT"><option value="PARENT" name="PARENT"><option value="" name=""><option value="" name=""><option value="" name=""><option value="" name=""><option value="" name=""></option></option> </select> <input type="submit"> 
  • The closing tag </ option> is incorrectly spelled out. They all gathered at the end. - ilyaplot
  • echo '</ option>'; there is the same - qaz qaz
  • Look at the source code, everything is not valid there. - ilyaplot

1 answer 1

 <?php $sql_s_core = "SELECT nameM FROM dbo.menu"; $result_core = sqlsrv_query($conn,$sql_s_core); while ($row_core = sqlsrv_fetch_array( $result_core,SQLSRV_FETCH_ASSOC)) { echo '<option value="'. $row_core['nameM'] . '" name="'. $row_core['nameM'] . '">'; echo $row_core['nameM']; echo '</option>'; } 

You forgot the parentheses of while. Without brackets, only the first line is looped.