Jump to content

drop down box problem!


grantypap

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/53713-drop-down-box-problem/
Share on other sites

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 
?>

Link to comment
https://forums.phpfreaks.com/topic/53713-drop-down-box-problem/#findComment-265472
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.