0

I have a drop-down list box which has to be populated from a database in mysql. I implemented the following code:

//DB Conn done here..
<td>College Name,id :</td>
<td><select><option selected="selected">Choose a college...</option>
<?php
$query="SELECT nameid from college";
$result=mysql_query($query);
while ($line = mysql_fetch_array($result))
{
	foreach ($line as $value)
	{
	echo "<OPTION value='$value'";
	}
echo ">$value</OPTION>";
}
mysql_close($link);
print "</SELECT>";
?>
</select>
</td>

My problem is a new line is inserted between each entry in the drop-down list box. Pls help me to remove that empty line.

2
Contributors
3
Replies
6
Views
7 Years
Discussion Span
Last Post by ﻼim
0

hey there hari!

try this :

<td>College Name ID :</td>
										<td><select name="collegeName" width = "200">
											<option value=''> Choose a college : </option>
											
											<?php
				
												$myquery=mysql_query("SELECT distinct nameid from college");
																		
													if(mysql_fetch_object($myquery) == null)
													{
														echo "<option value=''> No Record Found. </option>";
													}
																		
													else
													{	
																		
														$myquery=mysql_query("SELECT distinct nameid from college");	
																									
														while($collname=mysql_fetch_object($myquery))
														{
															echo "<option value='$collname->nameid'>".$collname->nameid."</option>";
														}
													} 
													
											?>
											
										</select></td>

i hope this helps .:)

0

Hey thanks for the help ﻼim. It works :)

no problem. :$
it's great to help you out with that.

don't forget to mark this thread as solved.
good luck! Ϋ
and happy day ahead!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.