grantypap Posted May 31, 2007 Share Posted May 31, 2007 hey guys, i've got a drop down box that is populated by the results of a mysql querie but for some reason it only shows the first word. so if i have the results; test 1 test 2 test 3 it will just display test. here is my code: print '<select name="Ans">'; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt print '<option value='.$nt['Ans'].'>'.$nt['Ans'].'</option>'; /* Option values are added by looping through the array */ } print '</select>';// Closing of list box any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/53713-drop-down-box-problem/ Share on other sites More sharing options...
Lumio Posted May 31, 2007 Share Posted May 31, 2007 Hmm... is it really only test 1 and so on? Not like test <1> or something like that... It is recommended to use htmlspecialchars... <?php print '<select name="Ans">'; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt print '<option value='.htmlspecialchars($nt['Ans']).'>'.htmlspecialchars($nt['Ans']).'</option>'; /* Option values are added by looping through the array */ } print '</select>';// Closing of list box ?> Quote Link to comment https://forums.phpfreaks.com/topic/53713-drop-down-box-problem/#findComment-265472 Share on other sites More sharing options...
grantypap Posted June 1, 2007 Author Share Posted June 1, 2007 im not to sure what you mean by that. looking at it again, it would seem that the drop down box displays the answers correctly but the problem comes when i try to write that value back to the database. Quote Link to comment https://forums.phpfreaks.com/topic/53713-drop-down-box-problem/#findComment-266209 Share on other sites More sharing options...
grantypap Posted June 1, 2007 Author Share Posted June 1, 2007 ok not to worry i just did a bit of googling and found another way of doing it. thanks for your help G Quote Link to comment https://forums.phpfreaks.com/topic/53713-drop-down-box-problem/#findComment-266240 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.