Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.